> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md).

# Class ksReflectionObject

Namespace: [KS.Unity.Editor](/reactor/api-reference/ks.unity.editor.md)\
Assembly: KSUnity-Editor.dll

Convencience class for accessing reflection data for an object, property, field, or type. When a reflection error occurs, an error is logged and a void reflection object is returned. All calls on void reflection objects return void reflection objects.

```csharp
public class ksReflectionObject
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Constructors

### ksReflectionObject(Type) <a href="#ks_unity_editor_ksreflectionobject__ctor_system_type" id="ks_unity_editor_ksreflectionobject__ctor_system_type"></a>

Type constructor

```csharp
public ksReflectionObject(Type type)
```

#### Parameters

`type` [Type](https://learn.microsoft.com/dotnet/api/system.type)

### ksReflectionObject(string, string, bool) <a href="#ks_unity_editor_ksreflectionobject__ctor_system_string_system_string_system_boolean" id="ks_unity_editor_ksreflectionobject__ctor_system_string_system_string_system_boolean"></a>

Constructor to load assembly and type by name.

```csharp
public ksReflectionObject(string assemblyName, string typeName, bool silent = false)
```

#### Parameters

`assemblyName` [string](https://learn.microsoft.com/dotnet/api/system.string)

`typeName` [string](https://learn.microsoft.com/dotnet/api/system.string)

`silent` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If true, no errors will be logged.

### ksReflectionObject(Assembly, string) <a href="#ks_unity_editor_ksreflectionobject__ctor_system_reflection_assembly_system_string" id="ks_unity_editor_ksreflectionobject__ctor_system_reflection_assembly_system_string"></a>

Constructor with assembly and name. Get the Type with name in the assembly.

```csharp
public ksReflectionObject(Assembly assembly, string typeName)
```

#### Parameters

`assembly` [Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly)

`typeName` [string](https://learn.microsoft.com/dotnet/api/system.string)

### ksReflectionObject(object) <a href="#ks_unity_editor_ksreflectionobject__ctor_system_object" id="ks_unity_editor_ksreflectionobject__ctor_system_object"></a>

Object constructor

```csharp
public ksReflectionObject(object value)
```

#### Parameters

`value` [object](https://learn.microsoft.com/dotnet/api/system.object)

### ksReflectionObject(object, PropertyInfo) <a href="#ks_unity_editor_ksreflectionobject__ctor_system_object_system_reflection_propertyinfo" id="ks_unity_editor_ksreflectionobject__ctor_system_object_system_reflection_propertyinfo"></a>

PropertyInfo constructor.

```csharp
public ksReflectionObject(object container, PropertyInfo propertyInfo)
```

#### Parameters

`container` [object](https://learn.microsoft.com/dotnet/api/system.object)

container for the property.

`propertyInfo` [PropertyInfo](https://learn.microsoft.com/dotnet/api/system.reflection.propertyinfo)

### ksReflectionObject(object, FieldInfo) <a href="#ks_unity_editor_ksreflectionobject__ctor_system_object_system_reflection_fieldinfo" id="ks_unity_editor_ksreflectionobject__ctor_system_object_system_reflection_fieldinfo"></a>

FieldInfo constructor

```csharp
public ksReflectionObject(object container, FieldInfo fieldInfo)
```

#### Parameters

`container` [object](https://learn.microsoft.com/dotnet/api/system.object)

container for the field.

`fieldInfo` [FieldInfo](https://learn.microsoft.com/dotnet/api/system.reflection.fieldinfo)

### ksReflectionObject(object, MethodInfo) <a href="#ks_unity_editor_ksreflectionobject__ctor_system_object_system_reflection_methodinfo" id="ks_unity_editor_ksreflectionobject__ctor_system_object_system_reflection_methodinfo"></a>

MethodInfo constructor

```csharp
public ksReflectionObject(object container, MethodInfo methodInfo)
```

#### Parameters

`container` [object](https://learn.microsoft.com/dotnet/api/system.object)

container for the method.

`methodInfo` [MethodInfo](https://learn.microsoft.com/dotnet/api/system.reflection.methodinfo)

### ksReflectionObject(ConstructorInfo) <a href="#ks_unity_editor_ksreflectionobject__ctor_system_reflection_constructorinfo" id="ks_unity_editor_ksreflectionobject__ctor_system_reflection_constructorinfo"></a>

ConstructorInfo constructor

```csharp
public ksReflectionObject(ConstructorInfo constructorInfo)
```

#### Parameters

`constructorInfo` [ConstructorInfo](https://learn.microsoft.com/dotnet/api/system.reflection.constructorinfo)

## Properties

### Container <a href="#ks_unity_editor_ksreflectionobject_container" id="ks_unity_editor_ksreflectionobject_container"></a>

Container object.

```csharp
public object Container { get; }
```

#### Property Value

[object](https://learn.microsoft.com/dotnet/api/system.object)

### FieldInfo <a href="#ks_unity_editor_ksreflectionobject_fieldinfo" id="ks_unity_editor_ksreflectionobject_fieldinfo"></a>

Represented field.

```csharp
public FieldInfo FieldInfo { get; }
```

#### Property Value

[FieldInfo](https://learn.microsoft.com/dotnet/api/system.reflection.fieldinfo)

### IsVoid <a href="#ks_unity_editor_ksreflectionobject_isvoid" id="ks_unity_editor_ksreflectionobject_isvoid"></a>

Is this a void reflection object? Void reflection objects are returned when a reflection error occurs. All calls on void reflection objects return void reflection objects.

```csharp
public bool IsVoid { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### PropertyInfo <a href="#ks_unity_editor_ksreflectionobject_propertyinfo" id="ks_unity_editor_ksreflectionobject_propertyinfo"></a>

Represented property.

```csharp
public PropertyInfo PropertyInfo { get; }
```

#### Property Value

[PropertyInfo](https://learn.microsoft.com/dotnet/api/system.reflection.propertyinfo)

### Type <a href="#ks_unity_editor_ksreflectionobject_type" id="ks_unity_editor_ksreflectionobject_type"></a>

Represented type.

```csharp
public Type Type { get; }
```

#### Property Value

[Type](https://learn.microsoft.com/dotnet/api/system.type)

### Void <a href="#ks_unity_editor_ksreflectionobject_void" id="ks_unity_editor_ksreflectionobject_void"></a>

Void reflection object. This is returned when a reflection error occurs. All calls on void reflection objects return void reflection objects.

```csharp
public static ksReflectionObject Void { get; }
```

#### Property Value

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

## Methods

### Call(string, params object\[]) <a href="#ks_unity_editor_ksreflectionobject_call_system_string_system_object" id="ks_unity_editor_ksreflectionobject_call_system_string_system_object"></a>

Calls a function on this object/type.

```csharp
public ksReflectionObject Call(string name, params object[] args)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of function.

`args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[]

args to call function with.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the return value, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if the function isn't found or returns null or void.

### Construct(params object\[]) <a href="#ks_unity_editor_ksreflectionobject_construct_system_object" id="ks_unity_editor_ksreflectionobject_construct_system_object"></a>

Calls a constructor for this type. Will try to determine which constructor to call from the argument types. Logs an error if which constructor to call cannot be determined.

```csharp
public ksReflectionObject Construct(params object[] args)
```

#### Parameters

`args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[]

args to pass to constructor.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for constructed object, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if the constructor could not be called.

### GetConstructor(params Type\[]) <a href="#ks_unity_editor_ksreflectionobject_getconstructor_system_type" id="ks_unity_editor_ksreflectionobject_getconstructor_system_type"></a>

Gets a constructor from this type.

```csharp
public ksReflectionObject GetConstructor(params Type[] paramTypes)
```

#### Parameters

`paramTypes` [Type](https://learn.microsoft.com/dotnet/api/system.type)\[]

Types of constructor's parameters.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the constructor, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if no constructor was found.

### GetConstructor(BindingFlags, bool, params Type\[]) <a href="#ks_unity_editor_ksreflectionobject_getconstructor_system_reflection_bindingflags_system_boolean_syst" id="ks_unity_editor_ksreflectionobject_getconstructor_system_reflection_bindingflags_system_boolean_syst"></a>

Gets a constructor from this type.

```csharp
public ksReflectionObject GetConstructor(BindingFlags bindingFlags, bool silent, params Type[] paramTypes)
```

#### Parameters

`bindingFlags` [BindingFlags](https://learn.microsoft.com/dotnet/api/system.reflection.bindingflags)

`silent` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

if true, no errors will be logged.

`paramTypes` [Type](https://learn.microsoft.com/dotnet/api/system.type)\[]

Types of constructor's parameters.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the constructor, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if no constructor was found.

### GetField(string, bool) <a href="#ks_unity_editor_ksreflectionobject_getfield_system_string_system_boolean" id="ks_unity_editor_ksreflectionobject_getfield_system_string_system_boolean"></a>

Gets a field from this object/type.

```csharp
public ksReflectionObject GetField(string name, bool silent = false)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of field.

`silent` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

if true, no errors will be logged.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the field, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if the field wasn't found.

### GetIndexedElement(int) <a href="#ks_unity_editor_ksreflectionobject_getindexedelement_system_int32" id="ks_unity_editor_ksreflectionobject_getindexedelement_system_int32"></a>

Gets an element from this object. This object must implement IList or IEnumerable.

```csharp
public ksReflectionObject GetIndexedElement(int index)
```

#### Parameters

`index` [int](https://learn.microsoft.com/dotnet/api/system.int32)

index of element to get.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

the element at the index, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if the element wasn't found.

### GetMethod(string, bool) <a href="#ks_unity_editor_ksreflectionobject_getmethod_system_string_system_boolean" id="ks_unity_editor_ksreflectionobject_getmethod_system_string_system_boolean"></a>

Gets a method from this object/type.

```csharp
public ksReflectionObject GetMethod(string name, bool silent)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of method.

`silent` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

if true, no errors will be logged.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the method, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if the method wasn't found.

### GetMethod(string, BindingFlags, Type\[], bool) <a href="#ks_unity_editor_ksreflectionobject_getmethod_system_string_system_reflection_bindingflags_system_typ" id="ks_unity_editor_ksreflectionobject_getmethod_system_string_system_reflection_bindingflags_system_typ"></a>

Gets a method from this object/type.

```csharp
public ksReflectionObject GetMethod(string name, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod, Type[] paramTypes = null, bool silent = false)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of method.

`bindingFlags` [BindingFlags](https://learn.microsoft.com/dotnet/api/system.reflection.bindingflags)

`paramTypes` [Type](https://learn.microsoft.com/dotnet/api/system.type)\[]

types of method' parameters.

`silent` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

if true, no errors will be logged.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the method, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if the method wasn't found.

### GetNestedType(string, BindingFlags) <a href="#ks_unity_editor_ksreflectionobject_getnestedtype_system_string_system_reflection_bindingflags" id="ks_unity_editor_ksreflectionobject_getnestedtype_system_string_system_reflection_bindingflags"></a>

Gets a nested type from this type.

```csharp
public ksReflectionObject GetNestedType(string name, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of nested type.

`bindingFlags` [BindingFlags](https://learn.microsoft.com/dotnet/api/system.reflection.bindingflags)

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the nested type, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if the type wasn't found.

### GetProperty(string, bool) <a href="#ks_unity_editor_ksreflectionobject_getproperty_system_string_system_boolean" id="ks_unity_editor_ksreflectionobject_getproperty_system_string_system_boolean"></a>

Gets a property from this object/type.

```csharp
public ksReflectionObject GetProperty(string name, bool silent = false)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of property.

`silent` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

if true, no errors will be logged.

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the property, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if the property wasn't found.

### GetValue(object) <a href="#ks_unity_editor_ksreflectionobject_getvalue_system_object" id="ks_unity_editor_ksreflectionobject_getvalue_system_object"></a>

Get value of the object, property, or field,

```csharp
public object GetValue(object instance = null)
```

#### Parameters

`instance` [object](https://learn.microsoft.com/dotnet/api/system.object)

instance to get value from. Use container object if not provided.

#### Returns

[object](https://learn.microsoft.com/dotnet/api/system.object)

Value of the object, property, or field.

### InstanceInvoke(object, params object\[]) <a href="#ks_unity_editor_ksreflectionobject_instanceinvoke_system_object_system_object" id="ks_unity_editor_ksreflectionobject_instanceinvoke_system_object_system_object"></a>

Invokes the method/constructor represented by this reflection object, if there is one. Does nothing otherwise.

```csharp
public object InstanceInvoke(object instance, params object[] args)
```

#### Parameters

`instance` [object](https://learn.microsoft.com/dotnet/api/system.object)

instance to call invoke method on

`args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[]

args to invoke method/constructor with.

#### Returns

[object](https://learn.microsoft.com/dotnet/api/system.object)

### InstanceInvokeThrowErrors(object, params object\[]) <a href="#ks_unity_editor_ksreflectionobject_instanceinvokethrowerrors_system_object_system_object" id="ks_unity_editor_ksreflectionobject_instanceinvokethrowerrors_system_object_system_object"></a>

Invokes the method/constructor represented by this reflection object, if there is one. Does nothing otherwise. Does not catch errors thrown by the invoked method.

```csharp
public object InstanceInvokeThrowErrors(object instance, params object[] args)
```

#### Parameters

`instance` [object](https://learn.microsoft.com/dotnet/api/system.object)

instance to call invoke method on

`args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[]

args to invoke method/constructor with.

#### Returns

[object](https://learn.microsoft.com/dotnet/api/system.object)

### Invoke(params object\[]) <a href="#ks_unity_editor_ksreflectionobject_invoke_system_object" id="ks_unity_editor_ksreflectionobject_invoke_system_object"></a>

Invokes the method/constructor represented by this reflection object, if there is one. Does nothing otherwise.

```csharp
public object Invoke(params object[] args)
```

#### Parameters

`args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[]

args to invoke method with.

#### Returns

[object](https://learn.microsoft.com/dotnet/api/system.object)

### InvokeThrowErrors(params object\[]) <a href="#ks_unity_editor_ksreflectionobject_invokethrowerrors_system_object" id="ks_unity_editor_ksreflectionobject_invokethrowerrors_system_object"></a>

Invokes the method/constructor represented by this reflection object, if there is one. Does nothing otherwise. Does not catch errors thrown by the invoked method.

```csharp
public object InvokeThrowErrors(params object[] args)
```

#### Parameters

`args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[]

args to invoke method with.

#### Returns

[object](https://learn.microsoft.com/dotnet/api/system.object)

### MakeGenericMethod(params Type\[]) <a href="#ks_unity_editor_ksreflectionobject_makegenericmethod_system_type" id="ks_unity_editor_ksreflectionobject_makegenericmethod_system_type"></a>

Sets the template types for generic method represnted by this object, or does nothing if there isn't one.

```csharp
public ksReflectionObject MakeGenericMethod(params Type[] templateTypes)
```

#### Parameters

`templateTypes` [Type](https://learn.microsoft.com/dotnet/api/system.type)\[]

Template types

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the method with the specified template types, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if a generic method could not be created.

### MakeGenericMethod(bool, params Type\[]) <a href="#ks_unity_editor_ksreflectionobject_makegenericmethod_system_boolean_system_type" id="ks_unity_editor_ksreflectionobject_makegenericmethod_system_boolean_system_type"></a>

Sets the template types for generic method represnted by this object, or does nothing if there isn't one.

```csharp
public ksReflectionObject MakeGenericMethod(bool silent, params Type[] templateTypes)
```

#### Parameters

`silent` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

if true, no errors will be logged.

`templateTypes` [Type](https://learn.microsoft.com/dotnet/api/system.type)\[]

Template types

#### Returns

[ksReflectionObject](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksreflectionobject.md)

Reflection object for the method with the specified template types, or [Void](#KS_Unity_Editor_ksReflectionObject_Void) if a generic method could not be created.

### SetValue(object) <a href="#ks_unity_editor_ksreflectionobject_setvalue_system_object" id="ks_unity_editor_ksreflectionobject_setvalue_system_object"></a>

Sets the value of the object, property, or field. Does nothing if this is a void reflection object.

```csharp
public void SetValue(object value)
```

#### Parameters

`value` [object](https://learn.microsoft.com/dotnet/api/system.object)

### SetValue(object, object) <a href="#ks_unity_editor_ksreflectionobject_setvalue_system_object_system_object" id="ks_unity_editor_ksreflectionobject_setvalue_system_object_system_object"></a>

Sets the value of the property or field. Does nothing if this is a void reflection object.

```csharp
public void SetValue(object instance, object value)
```

#### Parameters

`instance` [object](https://learn.microsoft.com/dotnet/api/system.object)

instance to set value on.

`value` [object](https://learn.microsoft.com/dotnet/api/system.object)
