Show / Hide Table of Contents

    Class TypeExtensions

    Extension methods for the System.Type.

    Inheritance
    System.Object
    TypeExtensions
    Namespace: Cuemon
    Assembly: Cuemon.Core.dll
    Syntax
    public static class TypeExtensions

    Methods

    | Improve this Doc

    GetAncestorsAndDescendantsAndSelf(Type)

    Gets a sorted (base-to-derived) sequence of ancestor-and-descendant-or-self types from the source.

    Declaration
    public static IEnumerable<Type> GetAncestorsAndDescendantsAndSelf(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to locate ancestor-and-descendant-or-self types from.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Type>

    An System.Collections.Generic.IEnumerable<T> holding the ancestor-and-descendant-or-self types from the source.

    | Improve this Doc

    GetAncestorsAndDescendantsAndSelf(Type, Assembly[])

    Gets a sorted (base-to-derived) sequence of ancestor-and-descendant-or-self types from the source.

    Declaration
    public static IEnumerable<Type> GetAncestorsAndDescendantsAndSelf(this Type source, params Assembly[] assemblies)
    Parameters
    Type Name Description
    System.Type source

    The source type to locate ancestor-and-descendant-or-self types from.

    System.Reflection.Assembly[] assemblies

    The assemblies to search for the source.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Type>

    An System.Collections.Generic.IEnumerable<T> holding the ancestor-and-descendant-or-self types from the source.

    | Improve this Doc

    GetAncestorsAndSelf(Type)

    Gets a sequence of ancestor-or-self types from the source.

    Declaration
    public static IEnumerable<Type> GetAncestorsAndSelf(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to locate ancestor-or-self types from.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Type>

    An System.Collections.Generic.IEnumerable<T> holding the ancestor-or-self types from the source.

    | Improve this Doc

    GetAncestorsAndSelf(Type, Type)

    Gets the ancestor-or-self System.Type from the specified source.

    Declaration
    public static Type GetAncestorsAndSelf(this Type source, Type sourceBaseLimit)
    Parameters
    Type Name Description
    System.Type source

    The source type to traverse.

    System.Type sourceBaseLimit

    The base limit of source.

    Returns
    Type Description
    System.Type

    The ancestor-or-self type from the specified source that is derived or equal to sourceBaseLimit.

    Exceptions
    Type Condition
    System.ArgumentNullException

    source - or - sourceBaseLimit is null.

    | Improve this Doc

    GetDefaultValue(Type)

    Gets the default value of the specified type.

    Declaration
    public static object GetDefaultValue(this Type type)
    Parameters
    Type Name Description
    System.Type type

    The System.Type to retrieve its default value from.

    Returns
    Type Description
    System.Object

    The default value of type.

    | Improve this Doc

    GetDescendantsAndSelf(Type)

    Gets a sequence of derived types from the source an it's associated System.Reflection.Assembly.

    Declaration
    public static IEnumerable<Type> GetDescendantsAndSelf(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to locate derived types from.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Type>

    An System.Collections.Generic.IEnumerable<T> holding the derived types from the source.

    | Improve this Doc

    GetDescendantsAndSelf(Type, Assembly[])

    Gets a sequence of derived types from the source.

    Declaration
    public static IEnumerable<Type> GetDescendantsAndSelf(this Type source, params Assembly[] assemblies)
    Parameters
    Type Name Description
    System.Type source

    The source type to locate derived types from.

    System.Reflection.Assembly[] assemblies

    The assemblies to search for the source.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Type>

    An System.Collections.Generic.IEnumerable<T> holding the derived types from the source.

    | Improve this Doc

    GetRuntimePropertiesExceptOf<T>(Type)

    Retrieves a collection that represents all the properties defined on a specified type except those defined on T.

    Declaration
    public static IEnumerable<PropertyInfo> GetRuntimePropertiesExceptOf<T>(this Type type)
    Parameters
    Type Name Description
    System.Type type

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

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo>

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

    Type Parameters
    Name Description
    T

    The type to exclude properties on type.

    | Improve this Doc

    HasAttributes(Type, Boolean, Type[])

    Determines whether the specified source type contains one or more of the specified attribute target types.

    Declaration
    public static bool HasAttributes(this Type source, bool inherit, params Type[] targets)
    Parameters
    Type Name Description
    System.Type source

    The source type to match against.

    System.Boolean inherit

    true to search the source inheritance chain to find the attributes; otherwise, false.

    System.Type[] targets

    The attribute target types to be matched against.

    Returns
    Type Description
    System.Boolean

    true if the specified source type contains one or more of the specified attribute target types; otherwise, false.

    | Improve this Doc

    HasAttributes(Type, Type[])

    Determines whether the specified source type contains one or more of the specified attribute target types.

    Declaration
    public static bool HasAttributes(this Type source, params Type[] targets)
    Parameters
    Type Name Description
    System.Type source

    The source type to match against.

    System.Type[] targets

    The attribute target types to be matched against.

    Returns
    Type Description
    System.Boolean

    true if the specified source type contains one or more of the specified attribute target types; otherwise, false.

    | Improve this Doc

    HasInterfaces(Type, Boolean, Type[])

    Determines whether the specified source contains one or more of the target types specified.

    Declaration
    public static bool HasInterfaces(this Type source, bool inherit, params Type[] targets)
    Parameters
    Type Name Description
    System.Type source

    The source type to match against.

    System.Boolean inherit

    Specifies whether to search this member's inheritance chain to find the interfaces.

    System.Type[] targets

    The target interface types to be matched against.

    Returns
    Type Description
    System.Boolean

    true if the specified source contains one or more of the target types specified; otherwise, false.

    | Improve this Doc

    HasInterfaces(Type, Type[])

    Determines whether the specified source contains one or more of the target types specified throughout this member's inheritance chain.

    Declaration
    public static bool HasInterfaces(this Type source, params Type[] targets)
    Parameters
    Type Name Description
    System.Type source

    The source type to match against.

    System.Type[] targets

    The target interface types to be matched against.

    Returns
    Type Description
    System.Boolean

    true if the specified source contains one or more of the target types specified throughout this member's inheritance chain; otherwise, false.

    | Improve this Doc

    HasTypes(Type, Type[])

    Determines whether the specified source type contains one or more of the specified target types.

    Declaration
    public static bool HasTypes(this Type source, params Type[] targets)
    Parameters
    Type Name Description
    System.Type source

    The source type to match against.

    System.Type[] targets

    The target types to be matched against.

    Returns
    Type Description
    System.Boolean

    true if the specified source contains one or more of the specified target types; otherwise, false.

    | Improve this Doc

    IsAnonymousMethod(Type)

    Determines whether the specified source is an anonymous method (be that in a form of a delegate or lambda expression).

    Declaration
    public static bool IsAnonymousMethod(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The System.Type to determine is an anonymous method.

    Returns
    Type Description
    System.Boolean

    true if the specified source is an anonymous method; otherwise, false.

    | Improve this Doc

    IsComparable(Type)

    Determines whether the specified source implements either System.IComparable or System.IComparable<T>.

    Declaration
    public static bool IsComparable(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to check for implements of either System.IComparable or System.IComparable<T>.

    Returns
    Type Description
    System.Boolean

    true if the specified source implements either System.IComparable or System.IComparable<T>; otherwise, false.

    | Improve this Doc

    IsComparer(Type)

    Determines whether the specified source implements either System.Collections.IComparer or System.Collections.Generic.IComparer<T>.

    Declaration
    public static bool IsComparer(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to check for implements of either System.Collections.IComparer or System.Collections.Generic.IComparer<T>.

    Returns
    Type Description
    System.Boolean

    true if the specified source implements either System.Collections.IComparer or System.Collections.Generic.IComparer<T>; otherwise, false.

    | Improve this Doc

    IsComplex(Type)

    Determines whether the specified source is a complex System.Type.

    Declaration
    public static bool IsComplex(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The System.Type to determine complexity for.

    Returns
    Type Description
    System.Boolean

    true if specified source is a complex System.Type; otherwise, false.

    Exceptions
    Type Condition
    System.ArgumentNullException

    source is null.

    | Improve this Doc

    IsDictionary(Type)

    Determines whether the specified source implements either System.Collections.IDictionary, System.Collections.Generic.IDictionary<TKey, TValue> or System.Collections.Generic.IReadOnlyDictionary<TKey, TValue>.

    Declaration
    public static bool IsDictionary(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to check for implements of either System.Collections.IDictionary, System.Collections.Generic.IDictionary<TKey, TValue> or System.Collections.Generic.IReadOnlyDictionary<TKey, TValue>

    Returns
    Type Description
    System.Boolean

    true if the specified source implements either System.Collections.IDictionary, System.Collections.Generic.IDictionary<TKey, TValue> or System.Collections.Generic.IReadOnlyDictionary<TKey, TValue>; otherwise, false.

    | Improve this Doc

    IsEnumerable(Type)

    Determines whether the specified source implements either System.Collections.IEnumerable or System.Collections.Generic.IEnumerable<T>.

    Declaration
    public static bool IsEnumerable(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to check for implements of either System.Collections.IEnumerable or System.Collections.Generic.IEnumerable<T>.

    Returns
    Type Description
    System.Boolean

    true if the specified source implements either System.Collections.IEnumerable or System.Collections.Generic.IEnumerable<T>; otherwise, false.

    | Improve this Doc

    IsEqualityComparer(Type)

    Determines whether the specified source implements either System.Collections.IEqualityComparer or System.Collections.Generic.IEqualityComparer<T>.

    Declaration
    public static bool IsEqualityComparer(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to check for implements of either System.Collections.IEqualityComparer or System.Collections.Generic.IEqualityComparer<T>.

    Returns
    Type Description
    System.Boolean

    true if the specified source implements either System.Collections.IEqualityComparer or System.Collections.Generic.IEqualityComparer<T>; otherwise, false.

    | Improve this Doc

    IsKeyValuePair(Type)

    Determines whether the specified source implements either System.Collections.DictionaryEntry or System.Collections.Generic.KeyValuePair<TKey,TValue>.

    Declaration
    public static bool IsKeyValuePair(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to check for implements of either System.Collections.DictionaryEntry or System.Collections.Generic.KeyValuePair<TKey,TValue>.

    Returns
    Type Description
    System.Boolean

    true if the specified source implements either System.Collections.DictionaryEntry or System.Collections.Generic.KeyValuePair<TKey,TValue>.; otherwise, false.

    | Improve this Doc

    IsNullable(Type)

    Determines whether the specified source is a nullable System.ValueType.

    Declaration
    public static bool IsNullable(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The source type to check for nullable System.ValueType.

    Returns
    Type Description
    System.Boolean

    true if the specified source is nullable; otherwise, false.

    | Improve this Doc

    IsSimple(Type)

    Determines whether the specified source is a simple System.Type.

    Declaration
    public static bool IsSimple(this Type source)
    Parameters
    Type Name Description
    System.Type source

    The System.Type to determine complexity for.

    Returns
    Type Description
    System.Boolean

    true if specified source is a simple System.Type; otherwise, false.

    Exceptions
    Type Condition
    System.ArgumentNullException

    source is null.

    | Improve this Doc

    ToFullNameIncludingAssemblyName(Type)

    Converts the System.Type to its equivalent string representation.

    Declaration
    public static string ToFullNameIncludingAssemblyName(this Type type)
    Parameters
    Type Name Description
    System.Type type

    The System.Type to extend.

    Returns
    Type Description
    System.String

    A string that contains the fully qualified name of the type, including its namespace, comma delimited with the simple name of the assembly.

    • Improve this Doc
    • View Source
    Back to top Copyright 2008-2018 Weubphoria. All rights reserved.
    Generated by DocFX