Class Reflection
Contains a series of functions that complement the reflection capabilities of C#, to conveniently allow for things like iterating over all types that a given type can be casted to.
Inheritance
Inherited Members
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public static class Reflection
Methods
| Improve this Doc View SourceGetRuntimeTypeTree(Object)
Gets the entire inheritanc/interface tree for the actual run-time type of the object passed in. This will include a type representing the actual run-time type of the object, as well as a type representing each superclass of that runtime type, and each interface that runtime type or one of its superclasses implement.
Declaration
public static IEnumerable<Type> GetRuntimeTypeTree(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Object to return type tree for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> | The complete inheritance/interface tree for the runtime-type of the object passed in, including the runtime type itself, and all superclasses of that type, as well as Type objects for each interface that runtime type or its superclasses implement. |
GetTypeTree(Type)
Gets the entire inheritance/interface tree for the type specified. This will include the type
itself,
as well as a Type representing each superclass of the type represented by type
, and each
interface that type
or its superclasses implement.
Declaration
public static IEnumerable<Type> GetTypeTree(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> | The complete interface/inheritance for the type represented by |
Remarks
This function may be somewhat expensive to compute, so if you plan to use it frequently it is recommended to cache the results.
GetTypeTree<T>()
Gets the entire inheritance/interface tree for type T. This will include a Type that represents type T, as well as a Type representing each superclass of T, and each interface that T or its superclasses implement.
Declaration
public static IEnumerable<Type> GetTypeTree<T>()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> | The complete interface/inheritance tree of T, including T, all superclasses, and all interfaces T or its superclasses implement. |
Type Parameters
Name | Description |
---|---|
T | Type to get inheritance/interface tree for. |
Remarks
This function may be somewhat expensive to compute, so if you plan to use it frequently it is recommended to cache the results.