Search Results for

    Show / Hide Table of Contents

    Class FieldAccessor<T, U>

    A type containing utilities for accessing non-public fields of objects.

    Inheritance
    System.Object
    FieldAccessor<T, U>
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: IPA.Utilities
    Assembly: IPA.Loader.dll
    Syntax
    public static class FieldAccessor<T, U>
    Type Parameters
    Name Description
    T

    the type that the fields are on

    U

    the type of the field to access

    Methods

    | Improve this Doc View Source

    Access(ref T, String)

    Accesses a field for an object by name.

    Declaration
    public static ref U Access(ref T obj, string name)
    Parameters
    Type Name Description
    T obj

    the object to access the field of

    System.String name

    the name of the field to access

    Returns
    Type Description
    U

    a reference to the object at the field

    Exceptions
    Type Condition
    System.MissingFieldException

    if the field does not exist on T

    See Also
    GetAccessor(String)
    | Improve this Doc View Source

    Get(T, String)

    Gets the value of a field of an object by name.

    Declaration
    public static U Get(T obj, string name)
    Parameters
    Type Name Description
    T obj

    the object to access the field of

    System.String name

    the name of the field to access

    Returns
    Type Description
    U

    the value of the field

    Exceptions
    Type Condition
    System.MissingFieldException

    if the field does not exist on T

    See Also
    Get(ref T, String)
    Access(ref T, String)
    GetAccessor(String)
    | Improve this Doc View Source

    Get(ref T, String)

    Gets the value of a field of an object by name.

    Declaration
    public static U Get(ref T obj, string name)
    Parameters
    Type Name Description
    T obj

    the object to access the field of

    System.String name

    the name of the field to access

    Returns
    Type Description
    U

    the value of the field

    Remarks

    The only good reason to use this over Get(T, String) is when you are working with a value type, as it prevents a copy.

    Exceptions
    Type Condition
    System.MissingFieldException

    if the field does not exist on T

    See Also
    Get(T, String)
    Access(ref T, String)
    GetAccessor(String)
    | Improve this Doc View Source

    GetAccessor(String)

    Gets an FieldAccessor<T, U>.Accessor for the field named name on T.

    Declaration
    public static FieldAccessor<T, U>.Accessor GetAccessor(string name)
    Parameters
    Type Name Description
    System.String name

    the field name

    Returns
    Type Description
    FieldAccessor.Accessor<>

    an accessor for the field

    Exceptions
    Type Condition
    System.MissingFieldException

    if the field does not exist on T

    | Improve this Doc View Source

    Set(T, String, U)

    Sets the value of a field for an object by name.

    Declaration
    public static void Set(T obj, string name, U value)
    Parameters
    Type Name Description
    T obj

    the object to set the field of

    System.String name

    the name of the field

    U value

    the value to set it to

    Remarks

    This overload cannot be safely used for value types. Use Set(ref T, String, U) instead.

    Exceptions
    Type Condition
    System.MissingFieldException

    if the field does not exist on T

    See Also
    Set(ref T, String, U)
    Access(ref T, String)
    GetAccessor(String)
    | Improve this Doc View Source

    Set(ref T, String, U)

    Sets the value of a field for an object by name.

    Declaration
    public static void Set(ref T obj, string name, U value)
    Parameters
    Type Name Description
    T obj

    the object to set the field of

    System.String name

    the name of the field

    U value

    the value to set it to

    Remarks

    This overload must be used for value types.

    Exceptions
    Type Condition
    System.MissingFieldException

    if the field does not exist on T

    See Also
    Set(T, String, U)
    Access(ref T, String)
    GetAccessor(String)

    See Also

    PropertyAccessor<T, U>
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX