Show / Hide Table of Contents

    Class ReflectionExtensions

    Inheritance
    Object
    ReflectionExtensions
    Namespace: QFSW.QC.Utilities
    Assembly: QFSW.QC.dll
    Syntax
    public static class ReflectionExtensions

    Methods

    AreMethodsEqual(MethodInfo, MethodInfo)

    Determines if two methods from different types have the same signature.

    Declaration
    public static bool AreMethodsEqual(MethodInfo a, MethodInfo b)
    Parameters
    Type Name Description
    MethodInfo a

    First method

    MethodInfo b

    Second method

    Returns
    Type Description
    Boolean

    true if they are equal

    Cast(Type, Object)

    Dynamically casts an object to the specified type.

    Declaration
    public static object Cast(this Type type, object data)
    Parameters
    Type Name Description
    Type type

    The destination type of the cast.

    Object data

    The object to cast.

    Returns
    Type Description
    Object

    The dynamically casted object.

    GetDisplayName(Type, Boolean)

    Gets a formatted display name for a given type.

    Declaration
    public static string GetDisplayName(this Type type, bool includeNamespace = false)
    Parameters
    Type Name Description
    Type type

    The type to generate a display name for.

    Boolean includeNamespace

    If the namespace should be included when generating the typename.

    Returns
    Type Description
    String

    The generated display name.

    HasAttribute<T>(ICustomAttributeProvider, Boolean)

    Gets if the provider has the specified attribute.

    Declaration
    public static bool HasAttribute<T>(this ICustomAttributeProvider provider, bool searchInherited = true)
    
        where T : Attribute
    Parameters
    Type Name Description
    ICustomAttributeProvider provider

    The attribute provider.

    Boolean searchInherited

    If base declarations should be searched.

    Returns
    Type Description
    Boolean

    If the attribute is present.

    Type Parameters
    Name Description
    T

    The attribute to test.

    IsCastableTo(Type, Type, Boolean)

    Determines if an object the given type can be casted to the specified type.

    Declaration
    public static bool IsCastableTo(this Type from, Type to, bool implicitly = false)
    Parameters
    Type Name Description
    Type from
    Type to

    The destination type of the cast.

    Boolean implicitly

    If only implicit casts should be considered.

    Returns
    Type Description
    Boolean

    If the cast can be performed.

    IsDelegate(FieldInfo)

    Determines if a field is a delegate.

    Declaration
    public static bool IsDelegate(this FieldInfo fieldInfo)
    Parameters
    Type Name Description
    FieldInfo fieldInfo
    Returns
    Type Description
    Boolean

    If the field is a delegate.

    IsDelegate(Type)

    Determines if a type is a delegate.

    Declaration
    public static bool IsDelegate(this Type type)
    Parameters
    Type Name Description
    Type type
    Returns
    Type Description
    Boolean

    If the type is a delegate.

    IsDerivedTypeOf(Type, Type)

    Determines if the type is a derived type of the given base type.

    Declaration
    public static bool IsDerivedTypeOf(this Type type, Type baseType)
    Parameters
    Type Name Description
    Type type
    Type baseType

    The base type to test against.

    Returns
    Type Description
    Boolean

    If the type is a derived type of the base type.

    IsGenericTypeOf(Type, Type)

    Determines if the type is a generic type of the given non-generic type.

    Declaration
    public static bool IsGenericTypeOf(this Type genericType, Type nonGenericType)
    Parameters
    Type Name Description
    Type genericType
    Type nonGenericType

    The non-generic type to test against.

    Returns
    Type Description
    Boolean

    If the type is a generic type of the non-generic type.

    IsOverride(MethodInfo)

    Determines if the given method is an override.

    Declaration
    public static bool IsOverride(this MethodInfo methodInfo)
    Parameters
    Type Name Description
    MethodInfo methodInfo
    Returns
    Type Description
    Boolean

    If the method is an override.

    IsStrongDelegate(FieldInfo)

    Determines if a field is a strongly typed delegate.

    Declaration
    public static bool IsStrongDelegate(this FieldInfo fieldInfo)
    Parameters
    Type Name Description
    FieldInfo fieldInfo

    The field to query.

    Returns
    Type Description
    Boolean

    If the field is a strongly typed delegate.

    IsStrongDelegate(Type)

    Determines if a type is a strongly typed delegate.

    Declaration
    public static bool IsStrongDelegate(this Type type)
    Parameters
    Type Name Description
    Type type
    Returns
    Type Description
    Boolean

    If the type is a strongly typed delegate.

    RebaseMethod(MethodInfo, Type)

    Rebases a method onto a new type by finding the corresponding method with an equal signature.

    Declaration
    public static MethodInfo RebaseMethod(this MethodInfo method, Type newBase)
    Parameters
    Type Name Description
    MethodInfo method

    Method to rebase

    Type newBase

    New type to rebase the method onto

    Returns
    Type Description
    MethodInfo

    The rebased method

    Quantum Console by QFSW
    Back to top