Пример #1
0
 public static void ShorterThan(int value, int minValue, string parameterName)
 {
     if (minValue > value)
     {
         throw new DomainException(DomainPreconditionMessages.GetShorterThan(minValue, parameterName));
     }
 }
Пример #2
0
 public static void EarlierThan(DateTime?value, DateTime dateToCompare, string parameterName)
 {
     if (value.HasValue && value.Value >= dateToCompare)
     {
         throw new DomainException(DomainPreconditionMessages.GetEarlierThan(dateToCompare, parameterName));
     }
 }
Пример #3
0
 public static void LengthEqualTo(string value, int requiredLength, string parameterName)
 {
     if (value?.Length != requiredLength)
     {
         throw new DomainException(DomainPreconditionMessages.GetLengthEqualTo(requiredLength, parameterName));
     }
 }
Пример #4
0
 public static void NotEmpty(byte[] value, string parameterName)
 {
     if (value.Length <= 0)
     {
         throw new DomainException(DomainPreconditionMessages.GetNotEmpty(parameterName));
     }
 }
Пример #5
0
 public static void LongerThan(int value, int maxValue, string parameterName)
 {
     if (value > maxValue)
     {
         throw new DomainException(DomainPreconditionMessages.GetLongerThan(maxValue, parameterName));
     }
 }
Пример #6
0
 public static void IsIntInIntList(IEnumerable <int> intList, int value, string parameterName)
 {
     if (intList.All(i => i != value))
     {
         throw new DomainException(DomainPreconditionMessages.IsIntInIntList(parameterName));
     }
 }
Пример #7
0
 public static void LessThanOrEqualTo(int quantity, int max, string parameterName)
 {
     if (quantity > max)
     {
         throw new DomainException(DomainPreconditionMessages.LessThanOrEqualTo(max, parameterName));
     }
 }
Пример #8
0
 public static void GreaterThan(decimal quantity, decimal min, string parameterName)
 {
     if (quantity <= min)
     {
         throw new DomainException(DomainPreconditionMessages.GreaterThan(min, parameterName));
     }
 }
Пример #9
0
 public static void EarlierOrEqualThan(DateTime start, DateTime end, string parameterName)
 {
     if (start > end)
     {
         throw new DomainException(DomainPreconditionMessages.GetEarlierOrEqualThan(end, parameterName));
     }
 }
Пример #10
0
 public static void NotEmpty(string value, string parameterName)
 {
     if (string.IsNullOrWhiteSpace(value))
     {
         throw new DomainException(DomainPreconditionMessages.GetNotEmpty(parameterName));
     }
 }
Пример #11
0
        public static IEnumerable <T> NotEmpty <T>(IEnumerable <T> values, string parameterName) where T : class
        {
            if (values != null && !values.Any())
            {
                throw new DomainException(DomainPreconditionMessages.GetNotEmptyCollection(parameterName));
            }

            return(values);
        }
Пример #12
0
        public static void RegexMatch(string value, Regex regex, string parameterName)
        {
            var match = regex.Match(value);

            if (!match.Success)
            {
                throw new DomainException(DomainPreconditionMessages.GetSuccessMatch(parameterName));
            }
        }
Пример #13
0
        public static T IntNotNull <T>(T value, int parameterName)
            where T : class
        {
            if (value is null)
            {
                throw new DomainException(DomainPreconditionMessages.GetNotNull(parameterName));
            }

            return(value);
        }