TypeDescription
public sealed class TypeDescription Describes a type. We use this class to wrap and return System.Type's that are safe to interact with. Returned by TypeLibrary.
Properties
| Name | Type | Description |
|---|---|---|
TargetType | Type | The type this class describes. |
BaseType | TypeDescription | The base type. This can return null if the type isn't in the type library! |
IsValid | Boolean | Whether the class is valid or not, i.e. whether the type still exists. |
Members | MemberDescription[] | All members (methods, properties, etc) of this type. |
DeclaredMembers | MemberDescription[] | Members (methods, properties, etc) declared by exactly this type, and not inherited. |
Methods | MethodDescription[] | All methods of this type. |
Properties | PropertyDescription[] | All properties of this type. |
Fields | FieldDescription[] | All fields on this type. |
IsInterface | Boolean | True if the target type is an interface |
IsEnum | Boolean | True if the target type is an enum |
IsStatic | Boolean | True if the target type is static |
IsClass | Boolean | True if the target type is a class |
IsValueType | Boolean | True if the target type is a value |
IsAbstract | Boolean | Gets a value indicating whether the System.Type is abstract and must be overridden. |
Name | String | Name of this type. |
Namespace | String | Namespace of this type. |
FullName | String | Full name of this type. |
Title | String | |
Description | String | |
Icon | String | |
Group | String | |
Order | Int32 | |
Tags | String[] | Tags are set via the [Tag] attribute |
Aliases | String[] | |
Identity | Int32 | An integer that represents this type. Based off the class name. |
ClassName | String | A string representing this class name. Historically this was provided by [Library( classname )]. If no special name is provided, this will be type.Name. |
SourceLine | Int32 | The line number of this member |
SourceFile | String | The file containing this member |
IsGenericType | Boolean | True if we're a generic type |
GenericArguments | Type[] | If we're a generic type this will return our generic parameters. |
Interfaces | Type[] | If we implement any interfaces they will be here |
Methods
Boolean IsNamed(String name, Boolean exactFullName = False) Returns true if this is named the passed name, either through classname, target class name or an alias
name — The name to check exactFullName — If true, only the exact full name or aliases will match. T GetAttribute(Boolean inherited = False) Returns the first attribute of given type, if any are present.
IEnumerable<T> GetAttributes(Boolean inherited = False) Returns all attributes of given type, if any are present.
Boolean HasAttribute(Boolean inherited = True) Returns true if the class has this attribute
Boolean HasTag(String tag) True if we have this tag.
PropertyDescription GetProperty(String name) Get property by name (will not find static properties)
PropertyDescription GetStaticProperty(String name) Get static property by name
Object GetValue(Object instance, String name) Get value by field or property name (will not find static members)
Object GetStaticValue(String name) Get value by field or property name, and which type the member is declared to store (will not find static members)
Boolean SetValue(Object instance, String name, Object value) Set value by field or property name (will not set static members)
Boolean SetStaticValue(String name, Object value) Set static value by field or property name
MethodDescription GetMethod(String name) Get a method by name (will not find static methods)
MethodDescription GetStaticMethod(String name) Get a method by name (will not find static methods)
T Create(Object[] args = null) Create an instance of this class, return it as a T. If it can't be cast to a T we won't create it and will return null.
T CreateGeneric(Type[] typeArgs = null, Object[] args = null) Create an instance of this class using generic arguments We're going to assume you know what you're doing here and let it throw any exceptions it wants.
Type MakeGenericType(Type[] inargs) For generic type definitions, create a type by substituting the given types for each type parameter. Returns null if any of the type arguments violate the generic constraints.