Class ReflectionUtility
- Namespace
- Homa.Sdk.Foundation
- Assembly
- Homa.Sdk.Foundation.dll
This class provides utility methods for type reflection, such as creating instances of types, or querying for types. It uses an underlying cache to speed up the reflection process, similar to the TypeCache in Unity's Editor assembly. Using string names of types supports types that were renamed or moved to another namespace, as long as they are marked with FormerlyKnownAsAttribute.
public static class ReflectionUtility
- Inheritance
-
ReflectionUtility
- Inherited Members
Methods
CreateInstance(string, params object[])
Creates an instance of an object or ScriptableObject of given type
public static object CreateInstance(string typeFullName, params object[] args)
Parameters
Returns
- object
Instance of specified type or null if it could not be created
CreateInstance(Type, params object[])
Creates an instance of an object or ScriptableObject of given type
public static object CreateInstance(Type type, params object[] args)
Parameters
Returns
- object
Instance of specified type
GetImplementingTypes(Type, TypeFilters)
Returns all types, that inherit from given base type
public static IEnumerable<Type> GetImplementingTypes(Type baseType, TypeFilters typeFilter)
Parameters
baseTypeTypeBase type
typeFilterTypeFiltersControl which types are being returned by the query
Returns
- IEnumerable<Type>
Enumerable of inheriting types
GetType(string)
Gets type based on it's full name from any available assembly that is not ignored
public static Type GetType(string fullName)
Parameters
fullNamestringFull name of type to retrieve.
Returns
- Type
Returns type if found, or null otherwise.
GetTypesWithAttribute<T>(TypeFilters)
Returns all types, that inherit from given base type
public static IEnumerable<Type> GetTypesWithAttribute<T>(TypeFilters typeFilter) where T : Attribute
Parameters
typeFilterTypeFiltersControl which types are being returned by the query
Returns
- IEnumerable<Type>
Enumerable of inheriting types
Type Parameters
T
InheritsOrImplements(Type, Type)
Checks if given type inherits from given base type, or implements it (when it's generic)
public static bool InheritsOrImplements(Type checkedType, Type baseType)
Parameters
Returns
- bool
trueif checked type inherits or implements baseType, otherwisefalse