Helper Scripts Collection 1.3.1
API documentation for the helper scripts compatible with Unity3D
Static Public Member Functions | List of all members
NikosAssets.Helpers.ReflectionHelper Class Reference

A helper class for reflections and type handling, such as finding parent types with generic arguments More...

Static Public Member Functions

static Type FindChildOfAncestor (Type descendant, Type ancestorToFind)
 Find the direct child of the desired ancestorToFind More...
 
static Type FindGenericTypeOfParentClassAtIndex (Type descendant, Type ancestorToFind, int i=0)
 Find a certain generic type at index i in the ancestorToFind More...
 
static List< Type > FindAllDerivedTypesAcrossAllAssemblies (Type rootType)
 Finds all from the given rootType derived types across all assemblies in this project. Note: Doesn't work with interfaces More...
 
static List< Type > FindAllDerivedTypes (Type rootType)
 Finds all from the given rootType derived types within the same assembly, the rootType is in. Note: Doesn't work with interfaces More...
 
static List< Type > FindAllDerivedTypes (Type rootType, Assembly assembly)
 Finds all from the given rootType derived types within the given assembly . Note: Doesn't work with interfaces More...
 
static List< Type > FindDirectChildrenOfTypeAcrossAllAssemblies (Type parentType)
 Finds all direct (first generation) child Types of the given parentType across all assemblies of this project. Note: Doesn't work with interfaces More...
 
static List< Type > FindDirectChildrenOfType (Type parentType)
 Finds all direct (first generation) child Types of the given parentType within its assembly. Note: Doesn't work with interfaces More...
 
static List< Type > FindDirectChildrenOfType (Type parentType, Assembly assembly)
 Finds all direct (first generation) child Types of the given parentType within the given assembly Note: Doesn't work with interfaces More...
 
static List< Type > FindInterfacesAcrossAllAssemblies (Type parentInterface, int maxInterfaces=1)
 Find "child" interfaces of the given parentInterface that contain a limited amount of other interfaces across all assemblies for this project More...
 
static List< Type > FindInterfaces (Type parentInterface, int maxInterfaces=1)
 Find "child" interfaces of the given parentInterface that contain a limited amount of other interfaces within the parentInterface 's assembly More...
 
static List< Type > FindInterfaces (Type parentInterface, Assembly assembly, int maxInterfaces=1)
 Find "child" interfaces of the given parentInterface that contain a limited amount of other interfaces within the given assembly More...
 

Detailed Description

A helper class for reflections and type handling, such as finding parent types with generic arguments

Member Function Documentation

◆ FindAllDerivedTypes() [1/2]

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindAllDerivedTypes ( Type  rootType)
static

Finds all from the given rootType derived types within the same assembly, the rootType is in. Note: Doesn't work with interfaces

Parameters
rootType
Returns
A list of the found child Types

◆ FindAllDerivedTypes() [2/2]

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindAllDerivedTypes ( Type  rootType,
Assembly  assembly 
)
static

Finds all from the given rootType derived types within the given assembly . Note: Doesn't work with interfaces

Parameters
rootType
assembly
Returns
A list of the found child Types

◆ FindAllDerivedTypesAcrossAllAssemblies()

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindAllDerivedTypesAcrossAllAssemblies ( Type  rootType)
static

Finds all from the given rootType derived types across all assemblies in this project. Note: Doesn't work with interfaces

Parameters
rootType
Returns
A list of the found child Types

◆ FindChildOfAncestor()

static Type NikosAssets.Helpers.ReflectionHelper.FindChildOfAncestor ( Type  descendant,
Type  ancestorToFind 
)
static

Find the direct child of the desired ancestorToFind

Parameters
descendantThe (grand) child we want to move up from
ancestorToFindThe child of this to find
Returns
null on fail, otherwise the first child Type of ancestorToFind

◆ FindDirectChildrenOfType() [1/2]

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindDirectChildrenOfType ( Type  parentType)
static

Finds all direct (first generation) child Types of the given parentType within its assembly. Note: Doesn't work with interfaces

Parameters
parentType
Returns
A list of the found child Types

◆ FindDirectChildrenOfType() [2/2]

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindDirectChildrenOfType ( Type  parentType,
Assembly  assembly 
)
static

Finds all direct (first generation) child Types of the given parentType within the given assembly Note: Doesn't work with interfaces

Parameters
parentType
assembly
Returns
A list of the found child Types

◆ FindDirectChildrenOfTypeAcrossAllAssemblies()

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindDirectChildrenOfTypeAcrossAllAssemblies ( Type  parentType)
static

Finds all direct (first generation) child Types of the given parentType across all assemblies of this project. Note: Doesn't work with interfaces

Parameters
parentType
Returns
A list of the found child Types

◆ FindGenericTypeOfParentClassAtIndex()

static Type NikosAssets.Helpers.ReflectionHelper.FindGenericTypeOfParentClassAtIndex ( Type  descendant,
Type  ancestorToFind,
int  i = 0 
)
static

Find a certain generic type at index i in the ancestorToFind

Parameters
descendant
ancestorToFind
i
Returns
null on fail, otherwise the generic Type at index i

◆ FindInterfaces() [1/2]

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindInterfaces ( Type  parentInterface,
Assembly  assembly,
int  maxInterfaces = 1 
)
static

Find "child" interfaces of the given parentInterface that contain a limited amount of other interfaces within the given assembly

Parameters
parentInterfaceThe "parent" interface to start the search from
assemblyThe assembly to search the interfaces
maxInterfacesYou can interpret this value as a maximum "child/ancestor" depth. It checks how many interfaces the current traversed interface contains/ implements
Returns
A list of the found "child" Type interfaces

◆ FindInterfaces() [2/2]

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindInterfaces ( Type  parentInterface,
int  maxInterfaces = 1 
)
static

Find "child" interfaces of the given parentInterface that contain a limited amount of other interfaces within the parentInterface 's assembly

Parameters
parentInterfaceThe "parent" interface to start the search from
maxInterfacesYou can interpret this value as a maximum "child/ancestor" depth. It checks how many interfaces the current traversed interface contains/ implements
Returns
A list of the found "child" Type interfaces

◆ FindInterfacesAcrossAllAssemblies()

static List< Type > NikosAssets.Helpers.ReflectionHelper.FindInterfacesAcrossAllAssemblies ( Type  parentInterface,
int  maxInterfaces = 1 
)
static

Find "child" interfaces of the given parentInterface that contain a limited amount of other interfaces across all assemblies for this project

Parameters
parentInterfaceThe "parent" interface to start the search from
maxInterfacesYou can interpret this value as a maximum "child/ancestor" depth. It checks how many interfaces the current traversed interface contains/ implements
Returns
A list of the found "child" Type interfaces