Show / Hide Table of Contents

# Class ReflectionUtil

A utility class providing reflection helper methods.

##### Inheritance

Object
ReflectionUtil

##### Inherited Members

Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()

###### Namespace: IPA.Utilities

###### Assembly: IPA.Loader.dll

##### Syntax

    public static class ReflectionUtil

### Methods

| Improve this Doc View Source

#### CallNonStaticMethod(String, String, String, Type[], Object[])

Calls an instance method on a type specified by `functionClass` and `dependency`.

##### Declaration

    public static object CallNonStaticMethod(string functionClass, string dependency, string function, Type[] methodSig, params object[] parameters)

##### Parameters

Type | Name | Description
--- | --- | ---
String | functionClass | the type name
String | dependency | the assembly the type is in
String | function | the name of the method to call
Type[] | methodSig | the type signature of the method
Object[] | parameters | the method parameters

##### Returns

Type | Description
--- | ---
Object | the result of the call

##### See Also

CallNonStaticMethod(Type, String, Type[], Object[])
| Improve this Doc View Source

#### CallNonStaticMethod(Type, String, Type[], Object[])

Calls an instance method on a new object.

##### Declaration

    public static object CallNonStaticMethod(this Type type, string function, Type[] methodSig, params object[] parameters)

##### Parameters

Type | Name | Description
--- | --- | ---
Type | type | the object type
String | function | the name of the method to call
Type[] | methodSig | the type signature
Object[] | parameters | the parameters

##### Returns

Type | Description
--- | ---
Object | the result of the call

| Improve this Doc View Source

#### CallNonStaticMethod<T>(Type, String, Type[], Object[])

Calls an instance method on a new object.

##### Declaration

    public static T CallNonStaticMethod<T>(this Type type, string function, Type[] methodSig, params object[] parameters)

##### Parameters

Type | Name | Description
--- | --- | ---
Type | type | the object type
String | function | the name of the method to call
Type[] | methodSig | the type signature
Object[] | parameters | the parameters

##### Returns

Type | Description
--- | ---
T | the result of the call

##### Type Parameters

Name | Description
--- | ---
T | the return type

##### See Also

CallNonStaticMethod(Type, String, Type[], Object[])
| Improve this Doc View Source

#### CopyComponent(Component, Type, GameObject, Type)

Copies a component `original` to a component of `overridingType` on the destination .

##### Declaration

    public static Component CopyComponent(this Component original, Type overridingType, GameObject destination, Type originalTypeOverride = null)

##### Parameters

Type | Name | Description
--- | --- | ---
Component | original | the original component
Type | overridingType | the new component's type
GameObject | destination | the destination GameObject
Type | originalTypeOverride | overrides the source component type (for example, to a superclass)

##### Returns

Type | Description
--- | ---
Component | the copied component

| Improve this Doc View Source

#### CopyComponent<T>(Component, GameObject, Type)

A generic version of CopyComponent(Component, Type, GameObject, Type).

##### Declaration

    public static T CopyComponent<T>(this Component original, GameObject destination, Type originalTypeOverride = null)
        where T : Component

##### Parameters

Type | Name | Description
--- | --- | ---
Component | original | the original component
GameObject | destination | the destination game object
Type | originalTypeOverride | overrides the source component type (for example, to a superclass)

##### Returns

Type | Description
--- | ---
T | the copied component

##### Type Parameters

Name | Description
--- | ---
T | the overriding type

##### See Also

CopyComponent(Component, Type, GameObject, Type)
| Improve this Doc View Source

#### GetPrivateField<T>(Object, String)

Gets the value of a (potentially) private field.

##### Declaration

    public static T GetPrivateField<T>(this object obj, string fieldName)

##### Parameters

Type | Name | Description
--- | --- | ---
Object | obj | the object instance to pull from
String | fieldName | the name of the field to read

##### Returns

Type | Description
--- | ---
T | the value of the field

##### Type Parameters

Name | Description
--- | ---
T | the type of te field (result casted)

| Improve this Doc View Source

#### InvokePrivateMethod(Object, String, Object[])

Invokes a (potentially) private method.

##### Declaration

    public static object InvokePrivateMethod(this object obj, string methodName, params object[] methodParams)

##### Parameters

Type | Name | Description
--- | --- | ---
Object | obj | the object to call from
String | methodName | the method name
Object[] | methodParams | the method parameters

##### Returns

Type | Description
--- | ---
Object | the return value

| Improve this Doc View Source

#### InvokePrivateMethod<T>(Object, String, Object[])

Invokes a (potentially) private method.

##### Declaration

    public static T InvokePrivateMethod<T>(this object obj, string methodName, params object[] methodParams)

##### Parameters

Type | Name | Description
--- | --- | ---
Object | obj | the object to call from
String | methodName | the method name to call
Object[] | methodParams | the method's parameters

##### Returns

Type | Description
--- | ---
T | the return value

##### Type Parameters

Name | Description
--- | ---
T | the return type

| Improve this Doc View Source

#### SetPrivateField(Object, String, Object)

Sets a (potentially) private field on the target object.

##### Declaration

    public static void SetPrivateField(this object obj, string fieldName, object value)

##### Parameters

Type | Name | Description
--- | --- | ---
Object | obj | the object instance
String | fieldName | the field to set
Object | value | the value to set it to

| Improve this Doc View Source

#### SetPrivateProperty(Object, String, Object)

Sets a (potentially) private property on the target object.

##### Declaration

    public static void SetPrivateProperty(this object obj, string propertyName, object value)

##### Parameters

Type | Name | Description
--- | --- | ---
Object | obj | the target object instance
String | propertyName | the name of the property
Object | value | the value to set it to