API reference
API reference
Select your platform
No SDKs available
No versions available

ReflectionUtils Class

A utility class for performing reflection operations. It provides methods to reflect the value of a field, property, or method from an object or a serialized property. It also caches the fields, properties, and methods to avoid repeated reflection.

Static Methods

ReflectFieldValue< T > ( obj , fieldName , data )
Reflects the value of a field from an object.
Signature
static bool Meta.WitAi.Utilities.ReflectionUtils.ReflectFieldValue< T >(object obj, string fieldName, out T data)
Parameters
obj: object  The object to reflect the field value from.
fieldName: string  The name of the field.
data: out T  The output parameter to store the reflected field value.
Returns
bool  True if the field exists, false otherwise.
ReflectMethodValue< T > ( obj , fieldName , data )
Reflects the value of a method from an object.
Signature
static bool Meta.WitAi.Utilities.ReflectionUtils.ReflectMethodValue< T >(object obj, string fieldName, out T data)
Parameters
obj: object  The object to reflect the method value from.
fieldName: string  The name of the method.
data: out T  The output parameter to store the reflected method value.
Returns
bool  True if the method exists, false otherwise.
ReflectPropertyValue< T > ( obj , fieldName , data )
Reflects the value of a property from an object.
Signature
static bool Meta.WitAi.Utilities.ReflectionUtils.ReflectPropertyValue< T >(object obj, string fieldName, out T data)
Parameters
obj: object  The object to reflect the property value from.
fieldName: string  The name of the property.
data: out T  The output parameter to store the reflected property value.
Returns
bool  True if the property exists, false otherwise.
ReflectValue< T > ( obj , fieldName )
Get the value of a field, property, or method that is passed in by name from an object.
Priority Search Order:
  1. Field
  2. Property
  3. Method
Signature
static T Meta.WitAi.Utilities.ReflectionUtils.ReflectValue< T >(object obj, string fieldName)
Parameters
obj: object  The object to reflect the value from.
fieldName: string  The name of the field, property, or method.
Returns
T
Throws
ArgumentException  Thrown when no field, property, or method is found with the given name.
TryReflectValue< T > ( obj , fieldName , value )
Get the value of a field, property, or method that is passed in by name from an object.
Priority Search Order:
  1. Field
  2. Property
  3. Method
Signature
static bool Meta.WitAi.Utilities.ReflectionUtils.TryReflectValue< T >(object obj, string fieldName, out T value)
Parameters
obj: object  The object to reflect the value from.
fieldName: string  The name of the field, property, or method.
value: out T  The resulting reflected value
Returns
bool

Internal Static Methods

GetAllAssignableTypes< T > ()
Retrieves all instantiatable types which are assignable from the given type T
Signature
static Type [] Meta.WitAi.Utilities.ReflectionUtils.GetAllAssignableTypes< T >()
Returns
Type []  a collection of types
GetMethodsWithAttribute< T > ()
Retrieves all methods which are tagged with the specified T attribute
Signature
static MethodInfo [] Meta.WitAi.Utilities.ReflectionUtils.GetMethodsWithAttribute< T >()
Returns
MethodInfo []
GetTypesWithAttribute< T > ()
Retrieves all classes which are tagged with the specified T attribute
Signature
static Type [] Meta.WitAi.Utilities.ReflectionUtils.GetTypesWithAttribute< T >()
Returns
Type []