| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using Abp.Collections.Extensions;
- using Abp.Extensions;
- using JetBrains.Annotations;
- namespace Abp
- {
- [DebuggerStepThrough]
- public static class Check
- {
- [ContractAnnotation("value:null => halt")]
- public static T NotNull<T>(T value, [InvokerParameterName] [NotNull] string parameterName)
- {
- if (value == null)
- {
- throw new ArgumentNullException(parameterName);
- }
- return value;
- }
- [ContractAnnotation("value:null => halt")]
- public static string NotNullOrEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)
- {
- if (value.IsNullOrEmpty())
- {
- throw new ArgumentException($"{parameterName} can not be null or empty!", parameterName);
- }
- return value;
- }
- [ContractAnnotation("value:null => halt")]
- public static string NotNullOrWhiteSpace(string value, [InvokerParameterName] [NotNull] string parameterName)
- {
- if (value.IsNullOrWhiteSpace())
- {
- throw new ArgumentException($"{parameterName} can not be null, empty or white space!", parameterName);
- }
- return value;
- }
- [ContractAnnotation("value:null => halt")]
- public static ICollection<T> NotNullOrEmpty<T>(ICollection<T> value, [InvokerParameterName] [NotNull] string parameterName)
- {
- if (value.IsNullOrEmpty())
- {
- throw new ArgumentException(parameterName + " can not be null or empty!", parameterName);
- }
- return value;
- }
- }
- }
|