Table of Contents

Class ReflectionHelper

Namespace
Nautilus.Utility
Assembly
Nautilus.dll
An extension method class for simplifying reflection calls for improved readability.
public static class ReflectionHelper
Inheritance
ReflectionHelper
Inherited Members

Methods

CopyFields<T>(T, T, BindingFlags)

Does a deep copy of all field values from the original instance onto the copied instance.
public static void CopyFields<T>(this T original, T copy, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

original T
The original instance.
copy T
The instance receiving the copied values.
bindingFlags BindingFlags
The additional binding flags you wish to set. Instance is already included.

Type Parameters

T
The class type of both objects.

GetInstanceField<T>(T, string, BindingFlags)

Gets the value of the requested private field, using reflection, from the instance object.
public static object GetInstanceField<T>(this T instance, string fieldName, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

instance T
The instance.
fieldName string
Name of the private field.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Instance are already included.

Returns

object
The value of the requested field as an object.

Type Parameters

T
The instance class type.

GetInstanceMethod<T>(string, BindingFlags)

Gets the MethodInfo of a private instance method, using refelction, from the specified class.
public static MethodInfo GetInstanceMethod<T>(string methodName, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

methodName string
Name of the method.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Instance are already included.

Returns

MethodInfo
The MethodInfo of the requested private method.

Type Parameters

T
The instance object type.

GetInstanceMethod<T>(T, string, BindingFlags)

Gets the MethodInfo of a private instance method, using refelction, from the instance object.
public static MethodInfo GetInstanceMethod<T>(this T instance, string methodName, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

instance T
The instance.
methodName string
Name of the method.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Instance are already included.

Returns

MethodInfo
The MethodInfo of the requested private method.

Type Parameters

T
The instance object type.

GetStaticField<T>(string, BindingFlags)

Gets the value of the requested private static field, using reflection, from the static object.
public static object GetStaticField<T>(string fieldName, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

fieldName string
Name of the field.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Static are already included.

Returns

object
The value of the requested static field as an object.

Type Parameters

T
The static class type.

GetStaticField<T>(T, string, BindingFlags)

Gets the value of the requested private static field, using reflection, from the instance object.
public static object GetStaticField<T>(this T instance, string fieldName, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

instance T
The instance.
fieldName string
Name of the field.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Static are already included.

Returns

object
The value of the requested static field as an object.

Type Parameters

T
The static class type.

GetStaticMethod<T>(string, BindingFlags)

Gets the MethodInfo of a private static method, using refelction, from the specified class.
public static MethodInfo GetStaticMethod<T>(string methodName, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

methodName string
Name of the method.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Static are already included.

Returns

MethodInfo
The MethodInfo of the requested private method.

Type Parameters

T
The object type.

GetStaticMethod<T>(T, string, BindingFlags)

Gets the MethodInfo of a private static method, using refelction, from the instance object.
public static MethodInfo GetStaticMethod<T>(this T instance, string methodName, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

instance T
The instance.
methodName string
Name of the method.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Static are already included.

Returns

MethodInfo
The MethodInfo of the requested private method.

Type Parameters

T
The object type.

SetInstanceField<T>(T, string, object, BindingFlags)

Sets the value of the requested private field, using reflection, on the instance object.
public static void SetInstanceField<T>(this T instance, string fieldName, object value, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

instance T
The instance.
fieldName string
Name of the private field.
value object
The value to set.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Instance are already included.

Type Parameters

T
The instance class type.

SetStaticField<T>(string, object, BindingFlags)

Sets the value of the requested private static field, using reflection, on the static object.
public static void SetStaticField<T>(string fieldName, object value, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

fieldName string
Name of the field.
value object
The value to set.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Static are already included.

Type Parameters

T
The static class type.

SetStaticField<T>(T, string, object, BindingFlags)

Sets the value of the requested private static field, using reflection, on the instance object.
public static void SetStaticField<T>(this T instance, string fieldName, object value, BindingFlags bindingFlags = BindingFlags.Default) where T : class

Parameters

instance T
The instance.
fieldName string
Name of the field.
value object
The value to set.
bindingFlags BindingFlags
The additional binding flags you wish to set. NonPublic and Static are already included.

Type Parameters

T
The static class type.