Exemple #1
0
        public T IsLt <T>(T value, T limit, [NotNull] IComparer <T> comparer, [InvokerParameterName] string paramName = Param.DefaultName, OptsFn optsFn = null)
        {
            if (!Ensure.IsActive)
            {
                return(value);
            }

            if (!value.IsLt(limit, comparer))
            {
                throw ExceptionFactory.ArgumentOutOfRangeException(ExceptionMessages.Comp_IsNotLt.Inject(value, limit), paramName, value, optsFn);
            }

            return(value);
        }
Exemple #2
0
        public T IsGte <T>([NotNull] T value, T limit, [InvokerParameterName] string paramName = Param.DefaultName, OptsFn optsFn = null) where T : IComparable <T>
        {
            if (!Ensure.IsActive)
            {
                return(value);
            }

            if (value.IsLt(limit))
            {
                throw ExceptionFactory.ArgumentOutOfRangeException(ExceptionMessages.Comp_IsNotGte.Inject(value, limit), paramName, value, optsFn);
            }

            return(value);
        }
Exemple #3
0
        public T IsInRange <T>(T value, T min, T max, [NotNull] IComparer <T> comparer, [InvokerParameterName] string paramName = Param.DefaultName, OptsFn optsFn = null)
        {
            if (!Ensure.IsActive)
            {
                return(value);
            }

            if (value.IsLt(min, comparer))
            {
                throw ExceptionFactory.ArgumentOutOfRangeException(ExceptionMessages.Comp_IsNotInRange_ToLow.Inject(value, min), paramName, value, optsFn);
            }

            if (value.IsGt(max, comparer))
            {
                throw ExceptionFactory.ArgumentOutOfRangeException(ExceptionMessages.Comp_IsNotInRange_ToHigh.Inject(value, max), paramName, value, optsFn);
            }

            return(value);
        }