From 34128a63aaac8171dc00d8d654f25f98f32b68ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 3 Apr 2020 11:40:23 +0300 Subject: [PATCH] Extract TypeHelper.IsNullable. --- .../Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs index b62f21f124..5f66f4788e 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using System.Reflection; @@ -15,7 +14,7 @@ namespace Volo.Abp.Reflection { return false; } - + var type = obj.GetType(); if (!type.GetTypeInfo().IsGenericType) { @@ -37,9 +36,7 @@ namespace Volo.Abp.Reflection return true; } - if (includeNullables && - type.IsGenericType && - type.GetGenericTypeDefinition() == typeof(Nullable<>)) + if (includeNullables && IsNullable(type)) { return IsPrimitiveExtendedInternal(type.GenericTypeArguments[0], includeEnums); } @@ -47,6 +44,11 @@ namespace Volo.Abp.Reflection return false; } + public static bool IsNullable(Type type) + { + return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); + } + public static Type GetFirstGenericArgumentIfNullable(this Type t) { if (t.GetGenericArguments().Length > 0 && t.GetGenericTypeDefinition() == typeof(Nullable<>))