Search Results for

    Show / Hide Table of Contents

    Class Reflection

    A collection of reflection related helper utilities.

    Inheritance
    System.Object
    Reflection
    Namespace: GDX
    Syntax
    public static class Reflection
    Remarks

    Torn about the existence of this utility class, yet alone the conditions dictating it.

    Fields

    | Improve this Doc View Source

    PrivateFieldFlags

    System.Reflection.BindingFlags for a private field.

    Declaration
    public const BindingFlags PrivateFieldFlags = BindingFlags.Instance | BindingFlags.NonPublic
    Field Value
    Type Description
    System.Reflection.BindingFlags
    | Improve this Doc View Source

    PrivateStaticFlags

    System.Reflection.BindingFlags for a private static.

    Declaration
    public const BindingFlags PrivateStaticFlags = BindingFlags.Static | BindingFlags.NonPublic
    Field Value
    Type Description
    System.Reflection.BindingFlags
    | Improve this Doc View Source

    PublicStaticFlags

    System.Reflection.BindingFlags for a public static.

    Declaration
    public const BindingFlags PublicStaticFlags = BindingFlags.Static | BindingFlags.Public
    Field Value
    Type Description
    System.Reflection.BindingFlags
    | Improve this Doc View Source

    SerializedTypesName

    The assembly qualified name for Serializable.SerializableTypes

    Declaration
    public static readonly string SerializedTypesName
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    UnityObjectName

    The assembly qualified name for UnityEngine.Object

    Declaration
    public static readonly string UnityObjectName
    Field Value
    Type Description
    System.String

    Methods

    | Improve this Doc View Source

    GetDefault(Type)

    Returns the default value for a given type.

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

    A qualified type.

    Returns
    Type Description
    System.Object

    The default value.

    | Improve this Doc View Source

    GetType(String)

    Returns a qualified type..

    Declaration
    public static Type GetType(string type)
    Parameters
    Type Name Description
    System.String type

    The full name of a type.

    Returns
    Type Description
    System.Type

    A System.Type if found.

    | Improve this Doc View Source

    GetTypeQualifiedName(Type)

    Returns a short form, non-versioned qualified name for the type.

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

    The System.Type to generate the qualified name for.

    Returns
    Type Description
    System.String

    A qualified name

    | Improve this Doc View Source

    InvokeMethod(Object, String, Object[], BindingFlags)

    Invoke a known private method on an object.

    Declaration
    public static object InvokeMethod(object targetObject, string method, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic)
    Parameters
    Type Name Description
    System.Object targetObject

    The ambiguous object to invoke a method on.

    System.String method

    The name of the method to invoke.

    System.Object[] parameters

    Any parameters that should be passed to the method?

    System.Reflection.BindingFlags flags

    The method's access flags.

    Returns
    Type Description
    System.Object

    An System.Object of the return value. This can be null.

    | Improve this Doc View Source

    InvokeStaticMethod(String, String, Object[], BindingFlags)

    Invokes a known static method.

    Declaration
    public static object InvokeStaticMethod(string type, string method, object[] parameters = null, BindingFlags flags = BindingFlags.Static | BindingFlags.Public)
    Parameters
    Type Name Description
    System.String type

    The explicit type of the static class.

    System.String method

    The name of the method to invoke.

    System.Object[] parameters

    Any parameters that should be passed to the method?

    System.Reflection.BindingFlags flags

    The method's access flags.

    Returns
    Type Description
    System.Object

    An System.Object of the return value. This can be null.

    | Improve this Doc View Source

    SetFieldOrPropertyValue(Object, String, Object, BindingFlags, BindingFlags)

    Set the field or property value of a specific targetObject, which may not be normally accessible.

    Declaration
    public static bool SetFieldOrPropertyValue(object targetObject, string name, object value, BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.NonPublic, BindingFlags propertyFlags = BindingFlags.Instance | BindingFlags.NonPublic)
    Parameters
    Type Name Description
    System.Object targetObject

    The instanced object which will have it's field or property value set.

    System.String name

    The field or property's name to set.

    System.Object value

    The value to set the field or property to.

    System.Reflection.BindingFlags fieldFlags

    The field's access flags.

    System.Reflection.BindingFlags propertyFlags

    The property's access flags.

    Returns
    Type Description
    System.Boolean

    true/false if the value was set.

    | Improve this Doc View Source

    SetFieldValue(Object, Type, String, Object, BindingFlags)

    Set the field value of a specific targetObject, which may not be normally accessible.

    Declaration
    public static bool SetFieldValue(object targetObject, Type type, string name, object value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic)
    Parameters
    Type Name Description
    System.Object targetObject

    The instanced object which will have it's field value set; use a null value if this is a static field.

    System.Type type

    The explicit type of the targetObject.

    System.String name

    The field's name to set.

    System.Object value

    The value to set the field to.

    System.Reflection.BindingFlags flags

    The field's access flags.

    Returns
    Type Description
    System.Boolean

    true/false if the value was set.

    | Improve this Doc View Source

    SetPropertyValue(Object, Type, String, Object, BindingFlags)

    Set the property value of a specific targetObject, which may not be normally accessible.

    Declaration
    public static bool SetPropertyValue(object targetObject, Type type, string name, object value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic)
    Parameters
    Type Name Description
    System.Object targetObject

    The instanced object which will have it's property value set; use a null value if this is a static property.

    System.Type type

    The type of the targetObject.

    System.String name

    The property's name to set.

    System.Object value

    The value to set the property to.

    System.Reflection.BindingFlags flags

    The property's access flags.

    Returns
    Type Description
    System.Boolean

    true/false if the value was set.

    | Improve this Doc View Source

    TryGetFieldOrPropertyValue(Object, String, out Object, BindingFlags, BindingFlags)

    Try to access the field or property value of a specific targetObject, which may not be normally accessible.

    Declaration
    public static bool TryGetFieldOrPropertyValue(object targetObject, string name, out object returnValue, BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.NonPublic, BindingFlags propertyFlags = BindingFlags.Instance | BindingFlags.NonPublic)
    Parameters
    Type Name Description
    System.Object targetObject

    The instanced object which will have it's field or property value read.

    System.String name

    The field or property's name to read.

    System.Object returnValue

    The returned value from the field or property, the default value if the property was unable to be read.

    System.Reflection.BindingFlags fieldFlags

    The field's access flags.

    System.Reflection.BindingFlags propertyFlags

    The property's access flags.

    Returns
    Type Description
    System.Boolean

    true/false if a value was found.

    Remarks

    Useful for when you really do not know the System.Type.

    | Improve this Doc View Source

    TryGetFieldValue<T>(Object, Type, String, out T, BindingFlags)

    Try to access the field value of a specific targetObject, which may not be normally accessible.

    Declaration
    public static bool TryGetFieldValue<T>(object targetObject, Type type, string name, out T returnValue, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic)
    Parameters
    Type Name Description
    System.Object targetObject

    The instanced object which will have it's field value read; use a null value if this is a static field.

    System.Type type

    The qualified type of the targetObject.

    System.String name

    The field's name to read.

    T returnValue

    The returned value from the field, the default value if the field was unable to be read.

    System.Reflection.BindingFlags flags

    The field's access flags.

    Returns
    Type Description
    System.Boolean

    true/false if the process was successful.

    Type Parameters
    Name Description
    T

    The type of data being read from the field.

    | Improve this Doc View Source

    TryGetPropertyValue<T>(Object, Type, String, out T, BindingFlags)

    Try to get a property value from targetObject, which may not be normally accessible.

    Declaration
    public static bool TryGetPropertyValue<T>(object targetObject, Type type, string name, out T returnValue, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic)
    Parameters
    Type Name Description
    System.Object targetObject

    The instanced object which will have it's property value read; use a null value if this is a static property.

    System.Type type

    The explicit type of the targetObject.

    System.String name

    The property's name to read.

    T returnValue

    The returned value from the property, the default value if the property was unable to be read.

    System.Reflection.BindingFlags flags

    The property's access flags.

    Returns
    Type Description
    System.Boolean

    true/false if the process was successful.

    Type Parameters
    Name Description
    T

    The type of data being read from the property.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Built on 2024-01-01 against 1f69a68.
    Generated by Dox+DocFX.