Class ResourceUtil
Summary description for ResourceUtil.
Inheritance
Namespace: ImageVault.Common.Lib.Reflection
Assembly: ImageVault.Common.dll
Syntax
public class ResourceUtil : Object
Remarks
2011-03-21 dan: Created
Constructors
ResourceUtil(Type)
Initializes a new instance of the ResourceUtil class.
Declaration
public ResourceUtil(Type baseType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | baseType |
Properties
BaseType
Get/Sets the BaseType of the ResourceUtil
Declaration
public Type BaseType { get; }
Property Value
Type | Description |
---|---|
System.Type |
Methods
GetEmbeddedBinaryData(String)
Retrieves the embedded resource as a byte array
Declaration
public byte[] GetEmbeddedBinaryData(string resourceName)
Parameters
Type | Name | Description |
---|---|---|
System.String | resourceName | The case-sensitive name of the manifest resource being requested. |
Returns
Type | Description |
---|---|
System.Byte[] | The retrieved System.Byte array |
GetEmbeddedBinaryData(Type, String)
Retrieves the embedded resource as a byte array
Declaration
public static byte[] GetEmbeddedBinaryData(Type baseType, string resourceName)
Parameters
Type | Name | Description |
---|---|---|
System.Type | baseType | The System.Type whose namespace is used to scope the manifest resource name. |
System.String | resourceName | The case-sensitive name of the manifest resource being requested. |
Returns
Type | Description |
---|---|
System.Byte[] | The retrieved System.Byte array |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
System.ApplicationException | If resource stream couldn't be opened |
GetManifestResourceStream(Assembly, String)
Gets the stream for the embedded resource
Declaration
public static Stream GetManifestResourceStream(Assembly assembly, string resourceName)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The System.Reflection.Assembly where the resource exists |
System.String | resourceName | The name of the resource |
Returns
Type | Description |
---|---|
System.IO.Stream | The found System.IO.Stream |
GetManifestResourceStream(Type, String)
Gets a manifest resource stream
Declaration
public static Stream GetManifestResourceStream(Type baseType, string resourceName)
Parameters
Type | Name | Description |
---|---|---|
System.Type | baseType | The System.Type whos assembly and namespace that should be used as base. |
System.String | resourceName | The name of the resource (omitting the basetypes namespace) |
Returns
Type | Description |
---|---|
System.IO.Stream | A System.IO.Stream representing the manifest resource; null if no resources were specified during compilation or if the resource is not visible to the caller. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
GetResourceNames(Type)
Gets the resourcenames from the same folder as the supplied baseType
Declaration
public static List<string> GetResourceNames(Type baseType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | baseType |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
ReadStringResource(Type, String)
Reads an embedded resource as a string
Declaration
public static string ReadStringResource(Type baseType, string resourceName)
Parameters
Type | Name | Description |
---|---|---|
System.Type | baseType | The System.Type whos assembly and namespace that should be used as base. |
System.String | resourceName | The name of the resource (omitting the basetypes namespace) |
Returns
Type | Description |
---|---|
System.String | The embedded resource in text format |
SaveEmbeddedFile(Assembly, String, String)
Saves an embedded resource as a file
Declaration
public static void SaveEmbeddedFile(Assembly assembly, string resourceName, string filename)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The System.Reflection.Assembly that contains the resource |
System.String | resourceName | The name of the resource |
System.String | filename | The output filename to write the resource to. |