Class EmbeddedResources
Utilities for embedded resources
Inheritance
Namespace:Dapplo.Addons.Bootstrapper.Resolving
Assembly:Dapplo.Addons.Bootstrapper.dll
Syntax
public static class EmbeddedResources : object
Methods
| Improve this Doc View SourceEmbeddedResourceExists(Uri, Boolean)
Test if there is an embedded resourcefor the Pack-Uri This is work in progress, as most of the times the files are compiled from xaml to baml, and won't be recognized when you specify a pack uri ending on .xaml
Declaration
public static bool EmbeddedResourceExists(this Uri packUri, bool ignoreCase = true)
Parameters
Type | Name | Description |
---|---|---|
Uri | packUri | Uri |
System.Boolean | ignoreCase | true to ignore the case |
Returns
Type | Description |
---|---|
System.Boolean | Stream |
FindEmbeddedResources(AppDomain, String, RegexOptions)
Scan the manifest of all assemblies in the AppDomain with a regex pattern for embedded resources Usually this would be used with AppDomain.Current
Declaration
public static IEnumerable<Tuple<Assembly, string>> FindEmbeddedResources(this AppDomain appDomain, string regexPattern, RegexOptions regexOptions = null)
Parameters
Type | Name | Description |
---|---|---|
AppDomain | appDomain | AppDomain to scan |
System.String | regexPattern | Regex pattern to scan for |
RegexOptions | regexOptions | RegexOptions.IgnoreCase as default |
Returns
Type | Description |
---|---|
IEnumerable<Tuple<Assembly, System.String>> | IEnumerable with matching assembly resource name tuples |
FindEmbeddedResources(Assembly, Regex)
Scan the manifest of the supplied Assembly with a regex pattern for embedded resources
Declaration
public static IEnumerable<string> FindEmbeddedResources(this Assembly assembly, Regex regexPattern)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | Assembly to scan |
Regex | regexPattern | Regex pattern to scan for |
Returns
Type | Description |
---|---|
IEnumerable<System.String> | IEnumerable with matching resource names |
FindEmbeddedResources(Assembly, String, RegexOptions)
Scan the manifest of the supplied Assembly with a regex pattern for embedded resources
Declaration
public static IEnumerable<string> FindEmbeddedResources(this Assembly assembly, string regexPattern, RegexOptions regexOptions = null)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | Assembly to scan |
System.String | regexPattern | Regex pattern to scan for |
RegexOptions | regexOptions | RegexOptions.IgnoreCase as default |
Returns
Type | Description |
---|---|
IEnumerable<System.String> | IEnumerable with matching resource names |
FindEmbeddedResources(IEnumerable<Assembly>, Regex)
Scan the manifest of the supplied Assembly elements with a regex pattern for embedded resources
Declaration
public static IEnumerable<Tuple<Assembly, string>> FindEmbeddedResources(this IEnumerable<Assembly> assemblies, Regex regex)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Assembly> | assemblies | IEnumerable with Assembly elements to scan |
Regex | regex | Regex to scan for |
Returns
Type | Description |
---|---|
IEnumerable<Tuple<Assembly, System.String>> | IEnumerable with matching resource names |
FindEmbeddedResources(IEnumerable<Assembly>, String, RegexOptions)
Scan the manifest of the supplied Assembly elements with a regex pattern for embedded resources
Declaration
public static IEnumerable<Tuple<Assembly, string>> FindEmbeddedResources(this IEnumerable<Assembly> assemblies, string regexPattern, RegexOptions regexOptions = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Assembly> | assemblies | IEnumerable with Assembly elements to scan |
System.String | regexPattern | Regex pattern to scan for |
RegexOptions | regexOptions | RegexOptions.IgnoreCase as default |
Returns
Type | Description |
---|---|
IEnumerable<Tuple<Assembly, System.String>> | IEnumerable with matching resource names |
FindEmbeddedResources(String, RegexOptions)
Scan the manifest of the calling Assembly with a regex pattern for embedded resources
Declaration
public static IEnumerable<string> FindEmbeddedResources(string regexPattern, RegexOptions regexOptions = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | regexPattern | Regex pattern to scan for |
RegexOptions | regexOptions | RegexOptions.IgnoreCase as default |
Returns
Type | Description |
---|---|
IEnumerable<System.String> | IEnumerable with matching resource names |
FindEmbeddedResources(Type, Regex)
Scan the manifest of the Assembly of the supplied Type with a regex pattern for embedded resources
Declaration
public static IEnumerable<string> FindEmbeddedResources(this Type type, Regex regex)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type is used to get the assembly |
Regex | regex | Regex to scan for |
Returns
Type | Description |
---|---|
IEnumerable<System.String> | IEnumerable with matching resource names |
FindEmbeddedResources(Type, String, RegexOptions)
Scan the manifest of the Assembly of the supplied Type with a regex pattern for embedded resources
Declaration
public static IEnumerable<string> FindEmbeddedResources(this Type type, string regexPattern, RegexOptions regexOptions = null)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type is used to get the assembly |
System.String | regexPattern | Regex pattern to scan for |
RegexOptions | regexOptions | RegexOptions.IgnoreCase as default |
Returns
Type | Description |
---|---|
IEnumerable<System.String> | IEnumerable with matching resource names |
GetEmbeddedResourceAsStream(Assembly, String, Boolean)
Get the stream for a assembly manifest resource based on the filePath It will automatically wrapped as GZipStream if the file-ending is .gz Note: a GZipStream is not seekable, this might cause issues.
Declaration
public static Stream GetEmbeddedResourceAsStream(this Assembly assembly, string filePath, bool ignoreCase = true)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | Assembly to look into |
System.String | filePath | string with the filepath to find |
System.Boolean | ignoreCase | true, which is default, to ignore the case when comparing |
Returns
Type | Description |
---|---|
Stream | Stream for the filePath, or null if not found |
GetEmbeddedResourceAsStream(String, Boolean)
Get the stream for the calling assembly from the manifest resource based on the filePath
Declaration
public static Stream GetEmbeddedResourceAsStream(string filePath, bool ignoreCase = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | string with the filepath to find |
System.Boolean | ignoreCase | true, which is default, to ignore the case when comparing |
Returns
Type | Description |
---|---|
Stream | Stream for the filePath, or null if not found |
GetEmbeddedResourceAsStream(Uri)
Returns the embedded resource, as specified in the Pack-Uri as a stream. This currently doesn't go into the embedded .g.resources files, this might be added later
Declaration
public static Stream GetEmbeddedResourceAsStream(this Uri packUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | packUri | Uri |
Returns
Type | Description |
---|---|
Stream | Stream |
HasEmbeddedDotResourcesResource(Assembly, String, Boolean)
check if there is any resource in the specified assembly's .g.resources which matches the Regex This is work in progress, as most of the times the files are compiled from xaml to baml, and won't be recognized when you specify .xaml
Declaration
public static bool HasEmbeddedDotResourcesResource(this Assembly assembly, string filePath, bool ignoreCase = true)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | Assembly |
System.String | filePath | filePath |
System.Boolean | ignoreCase | true to ignore the case |
Returns
Type | Description |
---|---|
System.Boolean | bool with true if there is a matching resource |
HasResource(Assembly, Regex)
check if there is any resource in the specified assembly which matches the Regex
Declaration
public static bool HasResource(this Assembly assembly, Regex regexPattern)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | Assembly |
Regex | regexPattern | Regex |
Returns
Type | Description |
---|---|
System.Boolean | bool with true if there is a matching resource |
PackUriMatch(Uri)
Helper method to create a regex match for the supplied Pack uri
Declaration
public static Match PackUriMatch(this Uri packUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | packUri | Uri |
Returns
Type | Description |
---|---|
Match | Match |