Class ReflectionUtility
Inherited Members
Namespace: IdleKit.Core
Assembly: cs.temp.dll.dll
Syntax
public static class ReflectionUtility
Properties
AllAssemblies
Declaration
public static Assembly[] AllAssemblies { get; }
Property Value
Type | Description |
---|---|
Assembly[] |
TypesCached
Declaration
public static bool TypesCached { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
CacheAllTypes()
Caches all Types from all available assemblies for fast lookups. Does nothing if types have already been cached.
This method will be called automatically if needed by other methods (e.g. GetTypeBy...) but can be called manually ahead of time.
Declaration
public static void CacheAllTypes()
GetConcreteTypesThatImplement<TInterface>()
Returns all concrete Types that implement the specified interface.
This method is quite expensive; be careful when using it repeatedly or at runtime.
Declaration
public static IEnumerable<Type> GetConcreteTypesThatImplement<TInterface>()
where TInterface : class
Returns
Type | Description |
---|---|
IEnumerable<Type> |
Type Parameters
Name | Description |
---|---|
TInterface |
GetNestedMember(Type, String)
Get a MemberInfo by path, diving recursively through subobjects if the path uses dot notation (i.e. SubObject.Property._field)
Declaration
public static MemberInfo GetNestedMember(Type type, string memberPath)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The root Type to start the search from. |
String | memberPath | The path to the member. Supports dot notation (i.e. SubObject.Property._field) |
Returns
Type | Description |
---|---|
MemberInfo | The expected MemberInfo if the path is resolved, otherwise null. |
GetTypeByClassName(String)
Returns a Type by its class name, or null if no matching Type is found.
It's recommended to use GetTypeByFullName instead, when possible, as class names may conflict across assemblies and namespaces.
Declaration
public static Type GetTypeByClassName(string className)
Parameters
Type | Name | Description |
---|---|---|
String | className |
Returns
Type | Description |
---|---|
Type |
GetTypeByFullName(String)
Returns a Type by its full assembly-qualified name, or null if no matching Type is found.
Declaration
public static Type GetTypeByFullName(string fullName)
Parameters
Type | Name | Description |
---|---|---|
String | fullName |
Returns
Type | Description |
---|---|
Type |
GetUnderlyingType(MemberInfo)
Returns the underlying Type of a MemberInfo.
i.e. If the member is a float Field, returns typeof(float).
Declaration
public static Type GetUnderlyingType(MemberInfo member)
Parameters
Type | Name | Description |
---|---|---|
MemberInfo | member |
Returns
Type | Description |
---|---|
Type |