Class ResourceManagement
Adds, replaces and reads embedded resources of an assembly's module.
public class ResourceManagement
- Inheritance
-
ResourceManagement
- Inherited Members
Constructors
ResourceManagement(AssemblyContext)
Initializes a new instance of the ResourceManagement class.
public ResourceManagement(AssemblyContext context)
Parameters
contextAssemblyContextThe context whose module resources are managed.
Methods
Add(string)
Adds a public embedded resource from a file, named after the file name.
public void Add(string path)
Parameters
pathstringPath of the file to embed.
Add(string, byte[])
Adds a public embedded resource from a byte array.
public void Add(string name, byte[] bytes)
Parameters
GetByteResource(string)
Gets the data of an embedded resource as a byte array.
public byte[] GetByteResource(string name)
Parameters
namestringThe resource name.
Returns
Exceptions
- InvalidCastException
A resource with that name exists but is not an embedded resource.
GetStreamResource(string)
Gets the data of an embedded resource as a stream.
public MemoryStream GetStreamResource(string name)
Parameters
namestringThe resource name.
Returns
- MemoryStream
A new MemoryStream positioned at the start, or null if no resource matches.
Exceptions
- InvalidCastException
A resource with that name exists but is not an embedded resource.
Replace(string)
Replaces the resource named after the file name with the file contents (the new resource is appended at the end of the list); does nothing if no such resource exists.
public void Replace(string path)
Parameters
pathstringPath of the file providing the new data.
Replace(string, byte[])
Replaces the first resource with the given name by removing it and appending a new one at the end of the resource list; does nothing if none exists.
public void Replace(string name, byte[] bytes)