Show / Hide Table of Contents

Class ResourceHelper

A helper class for extracting embedded resources from an assembly.

Inheritance
object
ResourceHelper
BrainSerializerBase<TState, TBot, TAction>
Implements
IResourceHelper
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Microsoft.XboxStudios.BotBrain.Composition
Assembly: BotBrain.Core.dll
Syntax
public class ResourceHelper : IResourceHelper

Constructors

View Source

ResourceHelper()

Initializes a new instance of the ResourceHelper class.

Declaration
public ResourceHelper()
View Source

ResourceHelper(string)

Initializes a new instance of the ResourceHelper class.

Declaration
public ResourceHelper(string outputFolder)
Parameters
Type Name Description
string outputFolder

The output folder to write to.

Fields

View Source

DefaultParametersFilename

The default name for the parameter metadata file.

Declaration
public const string DefaultParametersFilename = "parameters.json"
Field Value
Type Description
string
View Source

JsonFileExtension

The extension for json files.

Declaration
protected const string JsonFileExtension = "json"
Field Value
Type Description
string

Properties

View Source

BaseOutputFolder

Gets or sets the path to the output folder to write bot brain files.

Declaration
public string BaseOutputFolder { get; protected set; }
Property Value
Type Description
string

Methods

View Source

GetParameters(Assembly?, string?, string?)

Loads the parameter metadata file from the given assembly.

Declaration
public static IDictionary<string, ParameterMetadata> GetParameters(Assembly? assembly = null, string? parametersResourceFile = null, string? baseFolder = null)
Parameters
Type Name Description
Assembly assembly

The assembly.

string parametersResourceFile

The path to the parameters file. If null, the default value is used.

string baseFolder

The base folder within the assembly containing resources to extract.

Returns
Type Description
IDictionary<string, ParameterMetadata>

A mapping of parameter name to metadata.

View Source

GetResourcePath(string?)

Gets the output file path for the given resource.

Declaration
public string GetResourcePath(string? filepath = null)
Parameters
Type Name Description
string filepath

The resource file path.

Returns
Type Description
string

A file path.

View Source

SafeCombinePath(string?, string?)

Combines two strings into a path, or if one string is null the other is returned.

Declaration
protected static string SafeCombinePath(string? left, string? right)
Parameters
Type Name Description
string left

The left component.

string right

The right component.

Returns
Type Description
string

The path.

View Source

WriteNewResourcesToDisk(Assembly?, string?, string?)

Writes the embedded resources from the assembly to the disk, if newer files are found.

Declaration
public void WriteNewResourcesToDisk(Assembly? assembly = null, string? baseFolder = null, string? outputFolder = null)
Parameters
Type Name Description
Assembly assembly

The assembly.

string baseFolder

The folder in the assembly containing resource files.

string outputFolder

The output folder relative to BaseOutputFolder for the resources.

Remarks

This allows users to modify a copy of the embedded files.

View Source

WriteResourcesToDisk(Assembly?, string?, string?, Func<string, bool>?)

Writes the embedded resources from the assembly to the disk, if a predicate is met.

Declaration
public void WriteResourcesToDisk(Assembly? assembly = null, string? baseFolder = null, string? outputFolder = null, Func<string, bool>? predicate = null)
Parameters
Type Name Description
Assembly assembly

The assembly.

string baseFolder

The folder in the assembly containing resource files.

string outputFolder

The output folder relative to BaseOutputFolder for the resources.

Func<string, bool> predicate

The predicate.

Implements

IResourceHelper
  • View Source
In this article
Back to top Generated by DocFX