Class TypeExtensions
- Namespace
- Cuemon.Extensions.Reflection
- Assembly
- Cuemon.Extensions.Reflection.dll
Extension methods for the Type class.
public static class TypeExtensions
- Inheritance
-
TypeExtensions
Methods
GetAllEvents(Type, Action<MemberReflectionOptions>)
Retrieves a collection that represents all events defined on the specified source and its inheritance chain.
public static IEnumerable<EventInfo> GetAllEvents(this Type source, Action<MemberReflectionOptions> setup = null)
Parameters
sourceTypeThe Type to extend.
setupAction<MemberReflectionOptions>The MemberReflectionOptions which may be configured.
Returns
- IEnumerable<EventInfo>
An IEnumerable<T> that contains all EventInfo objects of the specified
sourceand its inheritance chain.
GetAllFields(Type, Action<MemberReflectionOptions>)
Retrieves a collection that represents all fields defined on the specified source and its inheritance chain.
public static IEnumerable<FieldInfo> GetAllFields(this Type source, Action<MemberReflectionOptions> setup = null)
Parameters
sourceTypeThe Type to extend.
setupAction<MemberReflectionOptions>The MemberReflectionOptions which may be configured.
Returns
- IEnumerable<FieldInfo>
An IEnumerable<T> that contains all FieldInfo objects of the specified
sourceand its inheritance chain.
GetAllMethods(Type, Action<MemberReflectionOptions>)
Retrieves a collection that represents all methods defined on the specified source and its inheritance chain.
public static IEnumerable<MethodInfo> GetAllMethods(this Type source, Action<MemberReflectionOptions> setup = null)
Parameters
sourceTypeThe Type to extend.
setupAction<MemberReflectionOptions>The MemberReflectionOptions which may be configured.
Returns
- IEnumerable<MethodInfo>
An IEnumerable<T> that contains all MethodInfo objects of the specified
sourceand its inheritance chain.
GetAllProperties(Type, Action<MemberReflectionOptions>)
Retrieves a collection that represents all properties defined on the specified source and its inheritance chain.
public static IEnumerable<PropertyInfo> GetAllProperties(this Type source, Action<MemberReflectionOptions> setup = null)
Parameters
sourceTypeThe Type to extend.
setupAction<MemberReflectionOptions>The MemberReflectionOptions which may be configured.
Returns
- IEnumerable<PropertyInfo>
An IEnumerable<T> that contains all PropertyInfo objects of the specified
sourceand its inheritance chain.
GetDerivedTypes(Type, params Assembly[])
Gets a collection (self-to-derived) of derived / descendant types of the source.
public static IEnumerable<Type> GetDerivedTypes(this Type source, params Assembly[] assemblies)
Parameters
sourceTypeThe Type to extend.
assembliesAssembly[]The assemblies to include in the search of derived types.
Returns
- IEnumerable<Type>
An IEnumerable<T> that contains the derived types of the
source.
Exceptions
- ArgumentNullException
sourcecannot be null.
GetEmbeddedResources(Type, string, ManifestResourceMatch)
Loads the embedded resources from the associated Assembly of the specified Type following the ManifestResourceMatch ruleset of match.
public static IDictionary<string, Stream> GetEmbeddedResources(this Type source, string name, ManifestResourceMatch match)
Parameters
sourceTypeThe source type to load the resource from.
namestringThe name of the resource being requested.
matchManifestResourceMatchThe match ruleset to apply.
Returns
- IDictionary<string, Stream>
A Stream representing the loaded resources; null if no resources were specified during compilation, or if the resource is not visible to the caller.
Exceptions
- ArgumentNullException
sourcecannot be null -or-namecannot be null.- ArgumentException
namecannot be empty or consist only of white-space characters.- InvalidEnumArgumentException
matchwas not in the range of valid values.
GetHierarchyTypes(Type, params Assembly[])
Gets a collection (inherited-to-self-to-derived) of inherited / ancestor and derived / descendant types of the source.
public static IEnumerable<Type> GetHierarchyTypes(this Type source, params Assembly[] assemblies)
Parameters
sourceTypeThe Type to extend.
assembliesAssembly[]The assemblies to include in the search of derived types.
Returns
- IEnumerable<Type>
An IEnumerable<T> that contains a sorted (base-to-derived) collection of inherited and derived types of the
source.
Exceptions
- ArgumentNullException
sourcecannot be null.
GetInheritedTypes(Type)
Gets a collection (inherited-to-self) of inherited / ancestor types of the source.
public static IEnumerable<Type> GetInheritedTypes(this Type source)
Parameters
Returns
- IEnumerable<Type>
An IEnumerable<T> that contains the inherited types of the
source.
Exceptions
- ArgumentNullException
sourcecannot be null.
GetRuntimePropertiesExceptOf<T>(Type)
Retrieves a collection that represents all the properties defined on a specified type except those defined on T.
public static IEnumerable<PropertyInfo> GetRuntimePropertiesExceptOf<T>(this Type type)
Parameters
typeTypeThe type that contains the properties to include except those defined on
T.
Returns
- IEnumerable<PropertyInfo>
A collection of properties for the specified
typeexcept those defined onT.
Type Parameters
TThe type to exclude properties on
type.
Exceptions
- ArgumentNullException
typecannot be null.
ToFullNameIncludingAssemblyName(Type)
Converts the Type to its equivalent string representation.
public static string ToFullNameIncludingAssemblyName(this Type type)
Parameters
Returns
- string
A string that contains the fully qualified name of the type, including its namespace, comma delimited with the simple name of the assembly.