maliming
4 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
1 changed files with
8 additions and
18 deletions
-
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; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Checks if value of type T (struct) is empty, default or null
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
/// <param name="value"></param>
|
|
|
|
/// <param name="parameterName"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
public static T NotDefaultorNull<T>( |
|
|
|
Nullable<T> value, |
|
|
|
public static T NotDefaultOrNull<T>( |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|