Namespace: | Sirenix.Utilities |
Assembly: | Sirenix.Utilities |
public static class TypeExtensions
public static readonly Dictionary<string, string> TypeNameAlternatives
public static bool AreGenericConstraintsSatisfiedBy(this MethodBase genericMethod, params Type[] parameters)
System.Reflection.MethodBase | genericMethod | |
System.Type[] | parameters |
System.Boolean |
public static bool AreGenericConstraintsSatisfiedBy(this Type genericType, params Type[] parameters)
System.Type | genericType | |
System.Type[] | parameters |
System.Boolean |
public static bool AreGenericConstraintsSatisfiedBy(Type[] definitions, Type[] parameters)
System.Type[] | definitions | |
System.Type[] | parameters |
System.Boolean |
public static bool GenericArgumentsContainsTypes(this Type type, params Type[] types)
System.Type | type | |
System.Type[] | types |
System.Boolean |
public static bool GenericParameterIsFulfilledBy(this Type genericParameterDefinition, Type parameterType)
System.Type | genericParameterDefinition | |
System.Type | parameterType |
System.Boolean |
public static IEnumerable<MemberInfo> GetAllMembers(this Type type, BindingFlags flags = BindingFlags.Default)
System.Type | type | |
System.Reflection.BindingFlags | flags |
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo> |
public static IEnumerable<MemberInfo> GetAllMembers(this Type type, string name, BindingFlags flags = BindingFlags.Default)
System.Type | type | |
System.String | name | |
System.Reflection.BindingFlags | flags |
System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo> |
public static IEnumerable<T> GetAllMembers<T>(this Type type, BindingFlags flags = BindingFlags.Default)
where T : MemberInfo
System.Type | type | |
System.Reflection.BindingFlags | flags |
System.Collections.Generic.IEnumerable<T> |
T |
public static Type[] GetArgumentsOfInheritedOpenGenericClass(this Type candidateType, Type openGenericType)
System.Type | candidateType | |
System.Type | openGenericType |
System.Type[] |
public static Type[] GetArgumentsOfInheritedOpenGenericInterface(this Type candidateType, Type openGenericInterfaceType)
System.Type | candidateType | |
System.Type | openGenericInterfaceType |
System.Type[] |
public static Type[] GetArgumentsOfInheritedOpenGenericType(this Type candidateType, Type openGenericType)
System.Type | candidateType | |
System.Type | openGenericType |
System.Type[] |
public static T GetAttribute<T>(this Type type, bool inherit)
where T : Attribute
System.Type | type | |
System.Boolean | inherit |
T |
T |
public static IEnumerable<Type> GetBaseClasses(this Type type, bool includeSelf = false)
System.Type | type | |
System.Boolean | includeSelf |
System.Collections.Generic.IEnumerable<System.Type> |
public static IEnumerable<Type> GetBaseTypes(this Type type, bool includeSelf = false)
System.Type | type | |
System.Boolean | includeSelf |
System.Collections.Generic.IEnumerable<System.Type> |
public static MethodInfo GetCastMethod(this Type from, Type to, bool requireImplicitCast = false)
System.Type | from | |
System.Type | to | |
System.Boolean | requireImplicitCast |
System.Reflection.MethodInfo |
public static Func<object, object> GetCastMethodDelegate(this Type from, Type to, bool requireImplicitCast = false)
System.Type | from | |
System.Type | to | |
System.Boolean | requireImplicitCast |
System.Func<System.Object, System.Object> |
public static Func<TFrom, TTo> GetCastMethodDelegate<TFrom, TTo>(bool requireImplicitCast = false)
System.Boolean | requireImplicitCast |
System.Func<TFrom, TTo> |
TFrom | |
TTo |
public static string GetCompilableNiceFullName(this Type type)
System.Type | type |
System.String |
public static string GetCompilableNiceName(this Type type)
System.Type | type |
System.String |
public static T GetCustomAttribute<T>(this Type type)
where T : Attribute
System.Type | type |
T |
T |
public static T GetCustomAttribute<T>(this Type type, bool inherit)
where T : Attribute
System.Type | type | |
System.Boolean | inherit |
T |
T |
public static IEnumerable<T> GetCustomAttributes<T>(this Type type)
where T : Attribute
System.Type | type |
System.Collections.Generic.IEnumerable<T> |
T |
public static IEnumerable<T> GetCustomAttributes<T>(this Type type, bool inherit)
where T : Attribute
System.Type | type | |
System.Boolean | inherit |
System.Collections.Generic.IEnumerable<T> |
T |
public static ulong GetEnumBitmask(object value, Type enumType)
System.Object | value | |
System.Type | enumType |
System.UInt64 |
public static Func<T, T, bool> GetEqualityComparerDelegate<T>()
System.Func<T, T, System.Boolean> |
T |
public static Type GetGenericBaseType(this Type type, Type baseType)
System.Type | type | |
System.Type | baseType |
System.Type |
public static Type GetGenericBaseType(this Type type, Type baseType, out int depthCount)
System.Type | type | |
System.Type | baseType | |
System.Int32 | depthCount |
System.Type |
public static string GetGenericConstraintsString(this Type type, bool useFullTypeNames = false)
System.Type | type | |
System.Boolean | useFullTypeNames |
System.String |
public static string GetGenericParameterConstraintsString(this Type type, bool useFullTypeNames = false)
System.Type | type | |
System.Boolean | useFullTypeNames |
System.String |
public static int GetInheritanceDistance(this Type type, Type baseType)
System.Type | type | |
System.Type | baseType |
System.Int32 |
public static object GetMemberValue(this MemberInfo member, object obj)
System.Reflection.MemberInfo | member | |
System.Object | obj |
System.Object |
public static string GetNiceFullName(this Type type)
System.Type | type |
System.String |
public static string GetNiceName(this Type type)
System.Type | type |
System.String |
public static MethodInfo GetOperatorMethod(this Type type, Operator op)
System.Type | type | |
Operator | op |
System.Reflection.MethodInfo |
public static MethodInfo GetOperatorMethod(this Type type, Operator op, Type leftOperand, Type rightOperand)
System.Type | type | |
Operator | op | |
System.Type | leftOperand | |
System.Type | rightOperand |
System.Reflection.MethodInfo |
public static MethodInfo[] GetOperatorMethods(this Type type, Operator op)
System.Type | type | |
Operator | op |
System.Reflection.MethodInfo[] |
public static Type GetReturnType(this MemberInfo memberInfo)
System.Reflection.MemberInfo | memberInfo |
System.Type |
public static bool HasParamaters(this MethodInfo methodInfo, IList<Type> paramTypes, bool inherit = true)
System.Reflection.MethodInfo | methodInfo | |
System.Collections.Generic.IList<System.Type> | paramTypes | |
System.Boolean | inherit |
System.Boolean |
public static bool ImplementsOpenGenericClass(this Type candidateType, Type openGenericType)
System.Type | candidateType | |
System.Type | openGenericType |
System.Boolean |
public static bool ImplementsOpenGenericInterface(this Type candidateType, Type openGenericInterfaceType)
System.Type | candidateType | |
System.Type | openGenericInterfaceType |
System.Boolean |
public static bool ImplementsOpenGenericType(this Type candidateType, Type openGenericType)
System.Type | candidateType | |
System.Type | openGenericType |
System.Boolean |
public static bool ImplementsOrInherits(this Type type, Type to)
System.Type | type | |
System.Type | to |
System.Boolean |
public static bool InheritsFrom(this Type type, Type baseType)
System.Type | type | |
System.Type | baseType |
System.Boolean |
public static bool InheritsFrom<TBase>(this Type type)
System.Type | type |
System.Boolean |
TBase |
public static bool IsCastableTo(this Type from, Type to, bool requireImplicitCast = false)
System.Type | from | |
System.Type | to | |
System.Boolean | requireImplicitCast |
System.Boolean |
public static bool IsCSharpKeyword(string identifier)
System.String | identifier |
System.Boolean |
public static bool IsDefined<T>(this Type type)
where T : Attribute
System.Type | type |
System.Boolean |
T |
public static bool IsDefined<T>(this Type type, bool inherit)
where T : Attribute
System.Type | type | |
System.Boolean | inherit |
System.Boolean |
T |
public static bool IsFullyConstructedGenericType(this Type type)
System.Type | type |
System.Boolean |
public static bool IsNullableType(this Type type)
System.Type | type |
System.Boolean |
public static bool IsValidIdentifier(string identifier)
System.String | identifier |
System.Boolean |
public static object[] SafeGetCustomAttributes(this Assembly assembly, Type type, bool inherit)
System.Reflection.Assembly | assembly | |
System.Type | type | |
System.Boolean | inherit |
System.Object[] |
public static Type[] SafeGetTypes(this Assembly assembly)
System.Reflection.Assembly | assembly |
System.Type[] |
public static bool SafeIsDefined(this Assembly assembly, Type attribute, bool inherit)
System.Reflection.Assembly | assembly | |
System.Type | attribute | |
System.Boolean | inherit |
System.Boolean |
public static void SetMemberValue(this MemberInfo member, object obj, object value)
System.Reflection.MemberInfo | member | |
System.Object | obj | |
System.Object | value |
public static bool TryInferGenericParameters(this Type genericTypeDefinition, out Type[] inferredParams, params Type[] knownParameters)
System.Type | genericTypeDefinition | |
System.Type[] | inferredParams | |
System.Type[] | knownParameters |
System.Boolean |