Table of Contents

Class TypeExtensions

Namespace
Cuemon.Extensions.Reflection
Assembly
Cuemon.Extensions.Reflection.dll

Extension methods for the System.Type class.

public static class TypeExtensions
Inheritance
Object
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

source Type

The System.Type to extend.

setup Action<MemberReflectionOptions>

The MemberReflectionOptions which may be configured.

Returns

IEnumerable<EventInfo>

An System.Collections.Generic.IEnumerable<T> that contains all System.Reflection.EventInfo objects of the specified source and 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

source Type

The System.Type to extend.

setup Action<MemberReflectionOptions>

The MemberReflectionOptions which may be configured.

Returns

IEnumerable<FieldInfo>

An System.Collections.Generic.IEnumerable<T> that contains all System.Reflection.FieldInfo objects of the specified source and 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

source Type

The System.Type to extend.

setup Action<MemberReflectionOptions>

The MemberReflectionOptions which may be configured.

Returns

IEnumerable<MethodInfo>

An System.Collections.Generic.IEnumerable<T> that contains all System.Reflection.MethodInfo objects of the specified source and 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

source Type

The System.Type to extend.

setup Action<MemberReflectionOptions>

The MemberReflectionOptions which may be configured.

Returns

IEnumerable<PropertyInfo>

An System.Collections.Generic.IEnumerable<T> that contains all System.Reflection.PropertyInfo objects of the specified source and its inheritance chain.

GetDerivedTypes(Type, 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

source Type

The System.Type to extend.

assemblies Assembly[]

The assemblies to include in the search of derived types.

Returns

IEnumerable<Type>

An System.Collections.Generic.IEnumerable<T> that contains the derived types of the source.

Exceptions

System.ArgumentNullException

source cannot be null.

GetEmbeddedResources(Type, String, ManifestResourceMatch)

Loads the embedded resources from the associated System.Reflection.Assembly of the specified System.Type following the ManifestResourceMatch ruleset of match.

public static IDictionary<string, Stream> GetEmbeddedResources(this Type source, string name, ManifestResourceMatch match)

Parameters

source Type

The source type to load the resource from.

name String

The name of the resource being requested.

match ManifestResourceMatch

The match ruleset to apply.

Returns

IDictionary<String, 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.

Exceptions

System.ArgumentNullException

source cannot be null -or- name cannot be null.

System.ArgumentException

name cannot be empty or consist only of white-space characters.

System.ComponentModel.InvalidEnumArgumentException

match was not in the range of valid values.

GetHierarchyTypes(Type, 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

source Type

The System.Type to extend.

assemblies Assembly[]

The assemblies to include in the search of derived types.

Returns

IEnumerable<Type>

An System.Collections.Generic.IEnumerable<T> that contains a sorted (base-to-derived) collection of inherited and derived types of the source.

Exceptions

System.ArgumentNullException

source cannot 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

source Type

The System.Type to extend.

Returns

IEnumerable<Type>

An System.Collections.Generic.IEnumerable<T> that contains the inherited types of the source.

Exceptions

System.ArgumentNullException

source cannot 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

type Type

The type that contains the properties to include except those defined on T.

Returns

IEnumerable<PropertyInfo>

A collection of properties for the specified type except those defined on T.

Type Parameters

T

The type to exclude properties on type.

Exceptions

System.ArgumentNullException

type cannot be null.

ToFullNameIncludingAssemblyName(Type)

Converts the System.Type to its equivalent string representation.

public static string ToFullNameIncludingAssemblyName(this Type type)

Parameters

type Type

The System.Type to extend.

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.