Class ResourceHelper
A helper class for extracting embedded resources from an assembly.
Implements
Inherited Members
Namespace: Microsoft.XboxStudios.BotBrain.Composition
Assembly: BotBrain.Core.dll
Syntax
public class ResourceHelper : IResourceHelper
Constructors
View SourceResourceHelper()
Initializes a new instance of the ResourceHelper class.
Declaration
public ResourceHelper()
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 SourceDefaultParametersFilename
The default name for the parameter metadata file.
Declaration
public const string DefaultParametersFilename = "parameters.json"
Field Value
Type | Description |
---|---|
string |
JsonFileExtension
The extension for json files.
Declaration
protected const string JsonFileExtension = "json"
Field Value
Type | Description |
---|---|
string |
Properties
View SourceBaseOutputFolder
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 SourceGetParameters(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. |
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. |
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. |
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.
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. |