Caching and Other Utilities
Reflection caching reduces code boilerplate and allows us to provide additional reflection utilities.
GetCachedX and GetCachedXNullable
GetCachedX and GetCachedXNullableAs an alternative to the normal GetX reflection methods, we provide GetCachedX and GetCachedXNullable methods. These are extension methods that are usable in place of the normal GetX methods.
All GetCachedX methods rely on their GetCachedXNullable equivalents, and work under the assumption the returned value is guaranteed to not be null. These methods do not have any BindingFlag parameters, as we instead search for all members regardless of access modifiers.
GetCachedMethod
GetCachedMethodGetCachedMethod is unique in that takes not only a String name, but also a Type[]? signature and int genericCount. These are respectully null and 0 by default, but are used in order to allow users to access overloads. signature describes the non-generic parameters, and genericCount denotes the amount of generic parameters a method has.
GetCachedConstructor
GetCachedConstructorGetCachedConstructor has an additional Type[] signature parameter, which must be provided in order to retrieve a constructor.
Utilities
Described below are the various utility methods provided by Tea Framework.
InvokeUnderlyingMethod
InvokeUnderlyingMethodInvokes a method defined in a FieldInfo or PropertyInfo's FieldType/PropertyType. Type[]? signature and int genericCount are the same as GetCachedMethod.
GetFieldValue
GetFieldValueReturns the value of the described field.
GetPropertyValue
GetPropertyValueReturns the value of the described property.
SetFieldValue
SetFieldValueSets the value of the described field.
SetPropertyValue
SetPropertyValueSets the value of the described property.
SetNewInstance
SetNewInstanceAllows you to either directly set the value of a FieldInfo/PropertyInfo or use one created from Activator.CreateInstance.
Last updated