Table of Contents

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

typeFullName string

Full name of the type

args object[]

Arguments for the type constructor

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

type Type

Type of which instance will be created

args object[]

Arguments for the type constructor

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

baseType Type

Base type

typeFilter TypeFilters

Control 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

fullName string

Full 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

typeFilter TypeFilters

Control 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

checkedType Type

Type being checked

baseType Type

Base type

Returns

bool

true if checked type inherits or implements baseType, otherwise false