Show / Hide Table of Contents

Class ReflectionUtil

A utility class providing reflection helper methods.

Inheritance
System.Object
ReflectionUtil
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 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
System.String functionClass

the type name

System.String dependency

the assembly the type is in

System.String function

the name of the method to call

System.Type[] methodSig

the type signature of the method

System.Object[] parameters

the method parameters

Returns
Type Description
System.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
System.Type type

the object type

System.String function

the name of the method to call

System.Type[] methodSig

the type signature

System.Object[] parameters

the parameters

Returns
Type Description
System.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
System.Type type

the object type

System.String function

the name of the method to call

System.Type[] methodSig

the type signature

System.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 UnityEngine.GameObject.

Declaration
public static Component CopyComponent(this Component original, Type overridingType, GameObject destination, Type originalTypeOverride = null)
Parameters
Type Name Description
UnityEngine.Component original

the original component

System.Type overridingType

the new component's type

UnityEngine.GameObject destination

the destination GameObject

System.Type originalTypeOverride

overrides the source component type (for example, to a superclass)

Returns
Type Description
UnityEngine.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
UnityEngine.Component original

the original component

UnityEngine.GameObject destination

the destination game object

System.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
System.Object obj

the object instance to pull from

System.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
System.Object obj

the object to call from

System.String methodName

the method name

System.Object[] methodParams

the method parameters

Returns
Type Description
System.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
System.Object obj

the object to call from

System.String methodName

the method name to call

System.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
System.Object obj

the object instance

System.String fieldName

the field to set

System.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
System.Object obj

the target object instance

System.String propertyName

the name of the property

System.Object value

the value to set it to

  • Improve this Doc
  • View Source
Back to top Generated by DocFX