internal static bool IsObject(this Type type) { bool result = type.IsClass && (type.BaseType == null) && !type.IsPointer; Debug.Assert(result == type.IsMscorlibType("System", "Object")); return(result); }
/// <summary> /// Returns type argument if the type is /// Nullable<T>, otherwise null. /// </summary> internal static Type GetNullableTypeArgument(this Type type) { if (type.IsMscorlibType("System", "Nullable`1")) { var typeArgs = type.GetGenericArguments(); if (typeArgs.Length == 1) { return(typeArgs[0]); } } return(null); }
internal static bool IsIEnumerableOfT(this Type type) { return(type.IsMscorlibType("System.Collections.Generic", "IEnumerable`1")); }
internal static bool IsIEnumerable(this Type type) { return(type.IsMscorlibType("System.Collections", "IEnumerable")); }
internal static bool IsVoid(this Type type) { return(type.IsMscorlibType("System", "Void") && !type.IsGenericType); }
internal static bool IsValueType(this Type type) { return(type.IsMscorlibType("System", "ValueType")); }
internal static bool IsUIntPtr(this Type type) => type.IsMscorlibType("System", "UIntPtr");