/// <summary> /// Tests if the provided type is nullable /// </summary> /// <param name="arg"></param> /// <returns></returns> public static bool IsNullableType(this Type arg) { if (NullableTypes.TryGetValue(arg, out var cachedResult)) { return(cachedResult); } var method = GenericGetDefaultValueMethod.MakeGenericMethod(arg); var defaultValueForType = method.Invoke(null, new object[] { }); var result = defaultValueForType == null; return(NullableTypes[arg] = result); }
private static object DefaultValueForType(Type t) { var method = GenericGetDefaultValueMethod.MakeGenericMethod(t); return(method.Invoke(null, new object[] { })); }