diff --git a/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs b/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs index 863cd12e96..f79f0a60a2 100644 --- a/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs +++ b/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs @@ -3,9 +3,6 @@ using System.Reflection; namespace Volo.Abp.Reflection { - /// - /// Some simple type-checking methods used internally. - /// public static class TypeHelper { public static bool IsFunc(object obj) @@ -29,39 +26,41 @@ namespace Volo.Abp.Reflection return obj != null && obj.GetType() == typeof(Func); } - public static bool IsPrimitiveExtendedIncludingNullable(Type type, bool includeEnums = false) + public static bool IsPrimitiveExtended(Type type, bool includeNullables = true, bool includeEnums = false) { - if (IsPrimitiveExtended(type, includeEnums)) + if (IsPrimitiveExtendedInternal(type, includeEnums)) { return true; } - if (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) + if (includeNullables && + type.IsGenericType && + type.GetGenericTypeDefinition() == typeof(Nullable<>)) { - return IsPrimitiveExtended(type.GenericTypeArguments[0], includeEnums); + return IsPrimitiveExtendedInternal(type.GenericTypeArguments[0], includeEnums); } return false; } - private static bool IsPrimitiveExtended(Type type, bool includeEnums) + private static bool IsPrimitiveExtendedInternal(Type type, bool includeEnums) { - if (type.GetTypeInfo().IsPrimitive) + if (type.IsPrimitive) { return true; } - if (includeEnums && type.GetTypeInfo().IsEnum) + if (includeEnums && type.IsEnum) { return true; } - return type == typeof (string) || - type == typeof (decimal) || - type == typeof (DateTime) || - type == typeof (DateTimeOffset) || - type == typeof (TimeSpan) || - type == typeof (Guid); + return type == typeof(string) || + type == typeof(decimal) || + type == typeof(DateTime) || + type == typeof(DateTimeOffset) || + type == typeof(TimeSpan) || + type == typeof(Guid); } } }