Anvil
Anvil.Services.ResourceManager Class Reference
+ Inheritance diagram for Anvil.Services.ResourceManager:
+ Collaboration diagram for Anvil.Services.ResourceManager:

Public Member Functions

string CreateResourceDirectory (string path, bool detectChanges=true)
 Adds the specified folder as a valid resource directory for all ResMan requests. More...
 
void DeleteTempResource (string resourceName)
 Deletes the temporary resource with the specified name. More...
 
IEnumerable< string > FindResourcesOfType (ResRefType type, bool moduleOnly=true)
 Gets all resource names for the specified type. More...
 
GffResourceGetGenericFile (string name, ResRefType type)
 Gets the specified Gff resource. More...
 
string GetNSSContents (string scriptName)
 Gets the contents of a .nss script file as a string. More...
 
byte?[] GetResourceData (string name, ResRefType type)
 Gets the raw data of the specified resource. More...
 
string? GetResourceText (string name, ResRefType type)
 Gets the raw text of the specified resource. More...
 
bool IsValidResource (string name, ResRefType type=ResRefType.UTC)
 Determines if the supplied resource exists and is of the specified type. More...
 
void WriteTempResource (string resourceName, byte[] data)
 Creates a temporary resource with the specified name. More...
 
void WriteTempResource (string resourceName, string text)
 Creates a temporary resource with the specified name. More...
 

Static Public Attributes

const int MaxNameLength = 16
 

Member Function Documentation

◆ CreateResourceDirectory()

string Anvil.Services.ResourceManager.CreateResourceDirectory ( string  path,
bool  detectChanges = true 
)
inline

Adds the specified folder as a valid resource directory for all ResMan requests.

Parameters
pathThe path to add.
detectChangesTrue if changes to the folder contents should be tracked for updates.
Returns
The assigned resman alias for the resource directory.
Exceptions
ArgumentOutOfRangeExceptionThrown if the specified directory does not exist.

◆ DeleteTempResource()

void Anvil.Services.ResourceManager.DeleteTempResource ( string  resourceName)
inline

Deletes the temporary resource with the specified name.

Parameters
resourceNameThe resource to delete.

◆ FindResourcesOfType()

IEnumerable<string> Anvil.Services.ResourceManager.FindResourcesOfType ( ResRefType  type,
bool  moduleOnly = true 
)
inline

Gets all resource names for the specified type.

Parameters
typeA resource type.
moduleOnlyIf true, only bundled module resources will be returned.
Returns
Any matching ResRef names, otherwise an empty enumeration.

◆ GetGenericFile()

GffResource? Anvil.Services.ResourceManager.GetGenericFile ( string  name,
ResRefType  type 
)
inline

Gets the specified Gff resource.

Parameters
nameThe resource name to fetch, without any filetype extensions.
typeThe type of the file/resource.
Returns
A GffResource representation of the specified resource if it exists, otherwise null.

◆ GetNSSContents()

string Anvil.Services.ResourceManager.GetNSSContents ( string  scriptName)
inline

Gets the contents of a .nss script file as a string.

Parameters
scriptNameThe name of the script to get the contents of.
Returns
The script file contents or "" on error.

◆ GetResourceData()

byte? [] Anvil.Services.ResourceManager.GetResourceData ( string  name,
ResRefType  type 
)
inline

Gets the raw data of the specified resource.

Parameters
nameThe resource name to retrieve.
typeThe type of resource to retrieve.
Returns
The raw data of the associated resource, otherwise null if the resource does not exist.

◆ GetResourceText()

string? Anvil.Services.ResourceManager.GetResourceText ( string  name,
ResRefType  type 
)
inline

Gets the raw text of the specified resource.

Parameters
nameThe resource name to retrieve.
typeThe type of resource to retrieve.
Returns
The raw text of the associated resource, otherwise null if the resource does not exist.

◆ IsValidResource()

bool Anvil.Services.ResourceManager.IsValidResource ( string  name,
ResRefType  type = ResRefType.UTC 
)
inline

Determines if the supplied resource exists and is of the specified type.

Parameters
nameThe resource name to check.
typeThe type of this resource.
Returns
true if the supplied resource exists and is of the specified type, otherwise false.

◆ WriteTempResource() [1/2]

void Anvil.Services.ResourceManager.WriteTempResource ( string  resourceName,
byte[]  data 
)
inline

Creates a temporary resource with the specified name.

Parameters
resourceNameThe resource name.
dataThe data to populate in the resource.

◆ WriteTempResource() [2/2]

void Anvil.Services.ResourceManager.WriteTempResource ( string  resourceName,
string  text 
)
inline

Creates a temporary resource with the specified name.

Parameters
resourceNameThe resource name.
textThe text to populate in the resource.

The documentation for this class was generated from the following file: