Extension methods for System.Type
.
More...
Static Public Member Functions | |
static string | GetPrettyName (this Type type, bool full=false) |
Get a pretty readable name of the type, even generic, optional to use the full name. More... | |
static object | GetDefault (this Type type) |
Get the default value of the type, just like default . More... | |
static bool | IsCreatable (this Type type, bool exception=false) |
Determine if able to create an instance of the type. More... | |
static Type | GetNestedType (this Type type, string name, bool isStatic) |
Get the named public or nonpublic nested type of the specified type. More... | |
static FieldInfo | GetField (this Type type, string name, bool isStatic, Type fieldType=null) |
Get the named public or nonpublic FieldInfo of the specified type. More... | |
static PropertyInfo | GetProperty (this Type type, string name, bool isStatic, Type propertyType=null, params Type[] indexTypes) |
Get the named public or nonpublic PropertyInfo of the specified type. More... | |
static MethodInfo | GetMethod (this Type type, string name, bool isStatic, Type returnType=null, params Type[] paramTypes) |
Get the named public or nonpublic MethodInfo of the specified type. More... | |
static bool | Is< T > (this Type type) |
Determine if the type is derived from the other type, or implements the interface. More... | |
static bool | Is (this Type type, Type other) |
Determine if the type is derived from the other type, or implements the interface. More... | |
static Type | GetItemType (this Type type) |
Return the element type of an array or list type, otherwise null . More... | |
static Type[] | GetParents (this Type type) |
Get the parent hierarchy array, sorted from self to root type. More... | |
static Type[] | GetChildren (this Type type, bool deep=false) |
Get all child types, excluding self, optional to find deep or directly inheritance only. More... | |
static Type[] | GetDerivatives (this Type type, params Assembly[] dlls) |
Get all types derived from the specified type. More... | |
static Type[] | FindTypes (this Assembly dll, Type type=null) |
Find all valid types in the assembly, optional to filter which derived from the specified type. More... | |
static string | GetLocation (this Assembly dll) |
Get the location path if valid, otherwise empty. More... | |
Extension methods for System.Type
.
3
|
static |
Get a pretty readable name of the type, even generic, optional to use the full name.
This doesn't handle anonymous types.
type | Type. |
full | If set to true use the full name. |
|
static |
Get the default value of the type, just like default
.
type | Type. |
|
static |
Determine if able to create an instance of the type.
This only checks some basic conditions and might be not precise:
false
only if it's interface, abstract, generic definition, delegate.type | Type. |
exception | If invalid, throw an exception or return false . |
true
, if creatable, false
otherwise.
|
static |
Get the named public or nonpublic nested type of the specified type.
type | Type. |
name | Type name. |
isStatic | If to get a static type. |
|
static |
Get the named public or nonpublic FieldInfo
of the specified type.
type | Type. |
name | Field name. |
isStatic | If to get a static field. |
fieldType | Field type. |
|
static |
Get the named public or nonpublic PropertyInfo
of the specified type.
type | Type. |
name | Property name. |
isStatic | If to get a static property. |
propertyType | Property type. |
indexTypes | Index types. |
|
static |
Get the named public or nonpublic MethodInfo
of the specified type.
type | Type. |
name | Method name. |
isStatic | If to get a static method. |
returnType | Return type. |
paramTypes | Parameter types. |
|
static |
Determine if the type is derived from the other type, or implements the interface.
T | The other type. |
type | Type. |
true
, if is, false
otherwise.
|
static |
Determine if the type is derived from the other type, or implements the interface.
type | Type. |
other | The other type. |
true
, if is, false
otherwise.
|
static |
Return the element type of an array or list type, otherwise null
.
type | Type. |
|
static |
Get the parent hierarchy array, sorted from self to root type.
type | Type. |
|
static |
Get all child types, excluding self, optional to find deep or directly inheritance only.
type | Type. |
deep | If set to true deep. |
|
static |
Get all types derived from the specified type.
type | Type. |
dlls | Assemblies to search within, or default from all assemblies. |
|
static |
Find all valid types in the assembly, optional to filter which derived from the specified type.
dll | Assembly. |
type | Type filter. |
|
static |
Get the location path if valid, otherwise empty.
dll | Assembly. |