Class ReflectionUtilityExtensions
This is an extension implementation of the most common methods on the ReflectionUtility class.
Inheritance
Namespace: Cuemon.Reflection
Assembly: Cuemon.Reflection.dll
Syntax
public static class ReflectionUtilityExtensions
Methods
| Improve this DocGetAssemblyTypes(Assembly)
Gets the types contained within the specified assembly
.
Declaration
public static IEnumerable<Type> GetAssemblyTypes(this Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The System.Reflection.Assembly to search the types from. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> | A sequence of all System.Type elements from the specified |
GetAssemblyTypes(Assembly, String)
Gets the types contained within the specified assembly
.
Declaration
public static IEnumerable<Type> GetAssemblyTypes(this Assembly assembly, string namespaceFilter)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The System.Reflection.Assembly to search the types from. |
System.String | namespaceFilter | The namespace filter to apply on the types in the |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> | A sequence of System.Type elements, matching the applied filter, from the specified |
GetAssemblyTypes(Assembly, String, Type)
Gets the types contained within the specified assembly
.
Declaration
public static IEnumerable<Type> GetAssemblyTypes(this Assembly assembly, string namespaceFilter, Type typeFilter)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The System.Reflection.Assembly to search the types from. |
System.String | namespaceFilter | The namespace filter to apply on the types in the |
System.Type | typeFilter | The type filter to apply on the types in the |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> | A sequence of System.Type elements, matching the applied filters, from the specified |
GetEmbeddedResource(Type, String)
Loads the embedded resource from the associated System.Reflection.Assembly of the specified System.Type.
Declaration
public static Stream GetEmbeddedResource(this Type source, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Type | source | The source type to load the resource from. |
System.String | name | The case-sensitive name of the resource being requested. |
Returns
Type | Description |
---|---|
System.IO.Stream | A System.IO.Stream representing the loaded resource; null if no resources were specified during compilation, or if the resource is not visible to the caller. |
GetEmbeddedResource(Type, String, ResourceMatch)
Loads the embedded resource from the associated System.Reflection.Assembly of the specified System.Type.
Declaration
public static Stream GetEmbeddedResource(this Type source, string name, ResourceMatch match)
Parameters
Type | Name | Description |
---|---|---|
System.Type | source | The source type to load the resource from. |
System.String | name | The case-sensitive name of the resource being requested. |
ResourceMatch | match | The match ruleset to apply. |
Returns
Type | Description |
---|---|
System.IO.Stream | A System.IO.Stream representing the loaded resource; null if no resources were specified during compilation, or if the resource is not visible to the caller. |
GetEmbeddedResources(Type, String, ResourceMatch)
Loads the embedded resources from the associated System.Reflection.Assembly of the specified System.Type following the ResourceMatch ruleset of match
.
Declaration
public static IEnumerable<Stream> GetEmbeddedResources(this Type source, string name, ResourceMatch match)
Parameters
Type | Name | Description |
---|---|---|
System.Type | source | The source type to load the resource from. |
System.String | name | The name of the resource being requested. |
ResourceMatch | match | The match ruleset to apply. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.IO.Stream> | A System.IO.Stream representing the loaded resources; null if no resources were specified during compilation, or if the resource is not visible to the caller. |
GetPropertyAttributes<TDecoration>(Type)
Gets a sequence of the specified TDecoration
attribute, narrowed to property attribute decorations.
Declaration
public static IDictionary<PropertyInfo, TDecoration[]> GetPropertyAttributes<TDecoration>(this Type source)
where TDecoration : Attribute
Parameters
Type | Name | Description |
---|---|---|
System.Type | source | The source type to locate |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Reflection.PropertyInfo, TDecoration[]> | An System.Collections.Generic.IEnumerable<T> of the specified |
Type Parameters
Name | Description |
---|---|
TDecoration | The type of the attribute to locate in |
Remarks
Searches the source
using the following System.Reflection.BindingFlags combination: BindingInstancePublicAndPrivateNoneInheritedIncludeStatic.
GetPropertyAttributes<TDecoration>(Type, BindingFlags)
Gets a sequence of the specified TDecoration
attribute, narrowed to property attribute decorations.
Declaration
public static IDictionary<PropertyInfo, TDecoration[]> GetPropertyAttributes<TDecoration>(this Type source, BindingFlags bindings)
where TDecoration : Attribute
Parameters
Type | Name | Description |
---|---|---|
System.Type | source | The source type to locate |
System.Reflection.BindingFlags | bindings | A bitmask comprised of one or more System.Reflection.BindingFlags that specify how the search is conducted. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Reflection.PropertyInfo, TDecoration[]> | An System.Collections.Generic.IEnumerable<T> of the specified |
Type Parameters
Name | Description |
---|---|
TDecoration | The type of the attribute to locate in |
IsAutoProperty(PropertyInfo)
Determines whether the specified property
is considered an automatic property implementation.
Declaration
public static bool IsAutoProperty(this PropertyInfo property)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.PropertyInfo | property | The property to check for automatic property implementation. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
ParseMethodParameters(Type, String, Object[])
Parses and returns a collection of key/value pairs representing the specified methodName
.
Declaration
public static IDictionary<string, object> ParseMethodParameters(this Type source, string methodName, params object[] methodParameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | source | The source to locate the specified |
System.String | methodName | The name of the method to parse on |
System.Object[] | methodParameters | A variable number of values passed to the |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> | A collection of key/value pairs representing the specified |
Remarks
This method will parse the specified methodName
for parameter names and tie them with methodParameters
.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | This exception is thrown if |
ArgumentEmptyException | This exception is thrown if |
System.ArgumentException | This exception is thrown if either of the following is true: |
ParseMethodParameters(Type, String, Type[], Object[])
Parses and returns a collection of key/value pairs representing the specified methodName
.
Declaration
public static IDictionary<string, object> ParseMethodParameters(this Type source, string methodName, Type[] methodSignature, params object[] methodParameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type | source | The source to locate the specified |
System.String | methodName | The name of the method to parse on |
System.Type[] | methodSignature | An array of System.Type objects representing the number, order, and type of the parameters for the method to get. |
System.Object[] | methodParameters | A variable number of values passed to the |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> | A collection of key/value pairs representing the specified |
Remarks
This method will parse the specified methodName
for parameter names and tie them with methodParameters
.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | This exception is thrown if |
ArgumentEmptyException | This exception is thrown if |
System.ArgumentException | This exception is thrown if either of the following is true: |