コード例 #1
0
        private static Argument <T> IsGreaterThanOrEqualToImpl <T>(Argument <T> argument, object limit)
        {
            if (argument.Value == null)
            {
                throw ExceptionFactory.CreateNullException(argument);
            }

            if (argument.CompareValueTo(limit) < 0)
            {
                throw ExceptionFactory.OutOfRange(
                          argument,
                          ExceptionMessages.Current.NotGreaterThanOrEqualTo.Inject(limit, argument.Value));
            }

            return(argument);
        }
コード例 #2
0
        public static Argument <T> IsInRange <T>(this Argument <T> argument, T min, T max)
            where T : IComparable <T>
        {
            if (argument.Value == null)
            {
                throw ExceptionFactory.CreateNullException(argument);
            }

            if (argument.CompareValueTo(min) < 0)
            {
                throw ExceptionFactory.OutOfRange(
                          argument,
                          ExceptionMessages.Current.NotInRange_TooLow.Inject(min, max));
            }

            if (argument.CompareValueTo(max) > 0)
            {
                throw ExceptionFactory.OutOfRange(
                          argument,
                          ExceptionMessages.Current.NotInRange_TooHigh.Inject(min, max));
            }

            return(argument);
        }