class MAGES::Utilities::ReflectionUtilities¶
Overview¶
Reflection utilities. More…
class ReflectionUtilities
{
public:
// methods
static System.Type[] GetAllDerivedTypes(
this System.AppDomain domain,
System.Type baseType
);
static System.Type FindNestedTypeByName(
this System.Type type,
string matchName,
System.Type optionalInherit = null
);
static System.Reflection.FieldInfo GetFieldByPath(
this System.Type type,
string path
);
static bool IsSubclassOrClassOf(this System.Type t, System.Type baseClass);
static System.Type[] GetAllTypesImplementingInterface< T >(this System.AppDomain domain);
static System.Type[] GetAllTypesImplementingInterface(
this System.AppDomain domain,
System.Type interfaceType
);
static IEnumerable GetAllStaticClassesWithAttribute(
this System.AppDomain domain,
System.Type attributeType
);
static IEnumerable GetAllStaticClassesWithAttribute< T >(this System.AppDomain domain);
};
Detailed Documentation¶
Reflection utilities.
Methods¶
static System.Type[] GetAllDerivedTypes(
this System.AppDomain domain,
System.Type baseType
)
Get all derived types.
Parameters:
domain |
Domain. |
baseType |
The types they should be a subclass of. |
Returns:
Array of System.Type.
static System.Type FindNestedTypeByName(
this System.Type type,
string matchName,
System.Type optionalInherit = null
)
Find a nested type by name and optional inheritance.
Parameters:
type |
The type. |
matchName |
The name to match (exact). |
optionalInherit |
The type that the return value should inherit from. Leave null to ignore. |
Returns:
The nested type of matchName.
static System.Reflection.FieldInfo GetFieldByPath(
this System.Type type,
string path
)
A rewrite of System.Type.GetField(string), that takes a path like “data.color”.
Parameters:
type |
The type. |
path |
The property path, with dots for each sub-member access. |
Returns:
The field info, if found.
static bool IsSubclassOrClassOf(this System.Type t, System.Type baseClass)
Returns true if the type is a subclass of the base class, or the base class itself.
Parameters:
t |
The type. |
baseClass |
The base class to check against. |
Returns:
True if t is either a derived class or the same as the base class.
static System.Type[] GetAllTypesImplementingInterface< T >(this System.AppDomain domain)
Get all types implementing an interface.
Parameters:
T |
The interface type. |
domain |
The app domain. |
Returns:
List of instantiable classes that implement T.
static System.Type[] GetAllTypesImplementingInterface(
this System.AppDomain domain,
System.Type interfaceType
)
Get all types implementing an interface.
Parameters:
domain |
The app domain. |
interfaceType |
The type of the interface. |
Returns:
List of instantiable classes that implement interfaceType.
static IEnumerableGetAllStaticClassesWithAttribute( this System.AppDomain domain, System.Type attributeType )
Get all classes that have a specific attribute attached..
Parameters:
domain |
App domain. |
attributeType |
The type of the attribute. |
Returns:
An enumerable of items that match the query.
static IEnumerableGetAllStaticClassesWithAttribute< T >(this System.AppDomain domain)
Get all classes that have a specific attribute attached..
Parameters:
T |
The type of the attribute. |
domain |
App domain. |
Returns:
An enumerable of items that match the query.