From c3d9f94f7928b3a8e825821346e9ba2ac1ada4b0 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 27 May 2022 08:48:25 +0800 Subject: [PATCH] Update Check.cs --- framework/src/Volo.Abp.Core/Volo/Abp/Check.cs | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs index 8979c897a3..a2448190a5 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs @@ -253,8 +253,6 @@ public static class Check return value; } - - public static Int16 Range( Int16 value, [InvokerParameterName][NotNull] string parameterName, @@ -340,29 +338,21 @@ public static class Check return value; } - /// - /// Checks if value of type T (struct) is empty, default or null - /// - /// - /// - /// - /// - /// - public static T NotDefaultorNull( - Nullable value, + public static T NotDefaultOrNull( + T? value, [InvokerParameterName][NotNull] string parameterName) where T : struct { - if (value.Equals(default(T))) + if (value == null) { - throw new ArgumentException($"{parameterName} has a default value or is empty!", parameterName); + throw new ArgumentException($"{parameterName} is null!", parameterName); } - else if (value.HasValue == false) + + if (value.Value.Equals(default(T))) { - throw new ArgumentException($"{parameterName} is null!", parameterName); + throw new ArgumentException($"{parameterName} has a default value!", parameterName); } - return (T)value; + return value.Value; } - }