Class FieldAccessor<T, U>
A type containing utilities for accessing non-public fields of objects.
Inherited Members
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 SourceAccess(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 |
| String | name | the name of the field to access |
Returns
| Type | Description |
|---|---|
| U | a reference to the object at the field |
Exceptions
| Type | Condition |
|---|---|
| MissingFieldException | if the field does not exist on |
See Also
| Improve this Doc View SourceGet(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 |
| String | name | the name of the field to access |
Returns
| Type | Description |
|---|---|
| U | the value of the field |
Exceptions
| Type | Condition |
|---|---|
| MissingFieldException | if the field does not exist on |
See Also
| Improve this Doc View SourceGet(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 |
| 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 |
|---|---|
| MissingFieldException | if the field does not exist on |
See Also
| Improve this Doc View SourceGetAccessor(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 |
|---|---|---|
| String | name | the field name |
Returns
| Type | Description |
|---|---|
| FieldAccessor.Accessor<> | an accessor for the field |
Exceptions
| Type | Condition |
|---|---|
| MissingFieldException | if the field does not exist on |
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 |
| 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 |
|---|---|
| MissingFieldException | if the field does not exist on |
See Also
| Improve this Doc View SourceSet(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 |
| 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 |
|---|---|
| MissingFieldException | if the field does not exist on |