Class TypeUtility
Syntax
public static class TypeUtility
Methods
AndBaseTypeAndInterfaces(Type)
Declaration
public static IEnumerable<Type> AndBaseTypeAndInterfaces(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
AndHierarchy(Type)
Declaration
public static IEnumerable<Type> AndHierarchy(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
AndInterfaces(Type)
Declaration
public static IEnumerable<Type> AndInterfaces(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
BaseTypeAndInterfaces(Type, Boolean)
Declaration
public static IEnumerable<Type> BaseTypeAndInterfaces(this Type type, bool inheritedInterfaces = true)
Parameters
Type |
Name |
Description |
Type |
type |
|
Boolean |
inheritedInterfaces |
|
Returns
CanMakeGenericTypeVia(Type, Type)
Declaration
public static bool CanMakeGenericTypeVia(this Type openConstructedType, Type closedConstructedType)
Parameters
Type |
Name |
Description |
Type |
openConstructedType |
|
Type |
closedConstructedType |
|
Returns
Default(Type)
Declaration
public static object Default(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
GetDictionaryItemType(Type, Boolean, Int32)
Declaration
public static Type GetDictionaryItemType(Type dictionaryType, bool allowNonGeneric, int genericArgumentIndex)
Parameters
Type |
Name |
Description |
Type |
dictionaryType |
|
Boolean |
allowNonGeneric |
|
Int32 |
genericArgumentIndex |
|
Returns
GetDictionaryKeyType(Type, Boolean)
Declaration
public static Type GetDictionaryKeyType(Type dictionaryType, bool allowNonGeneric)
Parameters
Type |
Name |
Description |
Type |
dictionaryType |
|
Boolean |
allowNonGeneric |
|
Returns
GetDictionaryValueType(Type, Boolean)
Declaration
public static Type GetDictionaryValueType(Type dictionaryType, bool allowNonGeneric)
Parameters
Type |
Name |
Description |
Type |
dictionaryType |
|
Boolean |
allowNonGeneric |
|
Returns
GetEnumerableElementType(Type, Boolean)
Declaration
public static Type GetEnumerableElementType(Type enumerableType, bool allowNonGeneric)
Parameters
Type |
Name |
Description |
Type |
enumerableType |
|
Boolean |
allowNonGeneric |
|
Returns
GetInterfaces(Type, Boolean)
Declaration
public static IEnumerable<Type> GetInterfaces(this Type type, bool includeInherited)
Parameters
Type |
Name |
Description |
Type |
type |
|
Boolean |
includeInherited |
|
Returns
GetListElementType(Type, Boolean)
Declaration
public static Type GetListElementType(Type listType, bool allowNonGeneric)
Parameters
Type |
Name |
Description |
Type |
listType |
|
Boolean |
allowNonGeneric |
|
Returns
GetTypesSafely(Assembly)
Declaration
public static IEnumerable<Type> GetTypesSafely(this Assembly assembly)
Parameters
Returns
Hierarchy(Type)
Declaration
public static IEnumerable<Type> Hierarchy(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
Instantiate(Type, Boolean, Object[])
Declaration
public static object Instantiate(this Type type, bool nonPublic = true, params object[] args)
Parameters
Returns
Instantiator(Type, Boolean)
Declaration
public static Func<object> Instantiator(this Type type, bool nonPublic = true)
Parameters
Returns
Instantiator(Type, Boolean, Type[])
Declaration
public static Func<object[], object> Instantiator(this Type type, bool nonPublic = true, params Type[] parameterTypes)
Parameters
Returns
IsAbstract(Type)
Declaration
public static bool IsAbstract(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
IsAssignableFrom(Type, Object)
Declaration
public static bool IsAssignableFrom(this Type type, object value)
Parameters
Returns
IsBasic(Type)
Declaration
public static bool IsBasic(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
IsConcrete(Type)
Declaration
public static bool IsConcrete(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
IsNullable(Type)
Declaration
public static bool IsNullable(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
IsNumeric(Type)
Declaration
public static bool IsNumeric(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
IsNumericConstruct(Type)
Declaration
public static bool IsNumericConstruct(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
IsReferenceType(Type)
Declaration
public static bool IsReferenceType(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
IsStatic(Type)
Declaration
public static bool IsStatic(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
IsStruct(Type)
Declaration
public static bool IsStruct(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
MakeGenericTypeVia(Type, Type, Dictionary<Type, Type>, Boolean)
Declaration
public static Type MakeGenericTypeVia(this Type openConstructedType, Type closedConstructedType, Dictionary<Type, Type> resolvedGenericParameters, bool safe = true)
Parameters
Returns
Namespace(Type)
Declaration
public static Namespace Namespace(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
PseudoDefault(Type)
Declaration
public static object PseudoDefault(this Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
ToShortString(Object, Int32)
Declaration
public static string ToShortString(this object o, int maxLength = 20)
Parameters
Returns
TryInstantiate(Type, Boolean, Object[])
Declaration
public static object TryInstantiate(this Type type, bool nonPublic = true, params object[] args)
Parameters
Returns
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.