public static void DecimalNotOutOfRange( decimal value, string paramName, decimal lowerBound, decimal upperBound, RangeEndPoints endPoints = RangeEndPoints.Inclusive) { #if DEBUG Validate.DecimalNotOutOfRange(value, paramName, lowerBound, upperBound, endPoints); #endif }
public static void DoubleNotOutOfRange( double value, string paramName, double lowerBound, double upperBound, RangeEndPoints endPoints = RangeEndPoints.Inclusive) { #if DEBUG Validate.DoubleNotOutOfRange(value, paramName, lowerBound, upperBound, endPoints); #endif }
public static void Int32NotOutOfRange( int value, string paramName, int lowerBound, int upperBound, RangeEndPoints endPoints = RangeEndPoints.Inclusive) { #if DEBUG Validate.Int32NotOutOfRange(value, paramName, lowerBound, upperBound, endPoints); #endif }
public static void DoubleNotOutOfRange( double value, string paramName, double lowerBound, double upperBound, RangeEndPoints endPoints = RangeEndPoints.Inclusive) { if (value.IsInvalidNumber()) { throw new ValidationException( new ArgumentOutOfRangeException(paramName, $"{ExMessage} (The {paramName} value is an invalid number).")); } switch (endPoints) { case RangeEndPoints.Inclusive: if (value < lowerBound || value > upperBound) { throw new ValidationException( new ArgumentOutOfRangeException( paramName, $"{ExMessage} (The {paramName} is not within the specified range [{lowerBound}, {upperBound}]. Value = {value}).")); } break; case RangeEndPoints.LowerExclusive: if (value <= lowerBound || value > upperBound) { throw new ValidationException( new ArgumentOutOfRangeException( paramName, $"{ExMessage} (The {paramName} is not within the specified range ({lowerBound}, {upperBound}]. Value = {value}).")); } break; case RangeEndPoints.UpperExclusive: if (value < lowerBound || value >= upperBound) { throw new ValidationException( new ArgumentOutOfRangeException( paramName, $"{ExMessage} (The {paramName} is not within the specified range [{lowerBound}, {upperBound}). Value = {value}.")); } break; case RangeEndPoints.Exclusive: if (value <= lowerBound || value >= upperBound) { throw new ValidationException( new ArgumentOutOfRangeException( paramName, $"{ExMessage} (The {paramName} is not within the specified range ({lowerBound}, {upperBound}). Value = {value}).")); } break; } }
public static void DecimalNotOutOfRange( decimal value, string paramName, decimal lowerBound, decimal upperBound, RangeEndPoints endPoints = RangeEndPoints.Inclusive) { switch (endPoints) { case RangeEndPoints.Inclusive: if (value < lowerBound || value > upperBound) { throw new ValidationException( new ArgumentOutOfRangeException( paramName, $"{ExMessage} (The {paramName} is not within the specified range [{lowerBound}, {upperBound}]. Value = {value}).")); } break; case RangeEndPoints.LowerExclusive: if (value <= lowerBound || value > upperBound) { throw new ValidationException( new ArgumentOutOfRangeException( paramName, $"{ExMessage} (The {paramName} is not within the specified range ({lowerBound}, {upperBound}]. Value = {value}).")); } break; case RangeEndPoints.UpperExclusive: if (value < lowerBound || value >= upperBound) { throw new ValidationException( new ArgumentOutOfRangeException( paramName, $"{ExMessage} (The {paramName} is not within the specified range [{lowerBound}, {upperBound}). Value = {value}.")); } break; case RangeEndPoints.Exclusive: if (value <= lowerBound || value >= upperBound) { throw new ValidationException( new ArgumentOutOfRangeException( paramName, $"{ExMessage} (The {paramName} is not within the specified range ({lowerBound}, {upperBound}). Value = {value}).")); } break; } }
internal static void NotOutOfRange( double value, string paramName, double lowerBound = double.MinValue, double upperBound = double.MaxValue, RangeEndPoints endPoints = RangeEndPoints.Inclusive) { NotInvalidNumber(value, paramName); switch (endPoints) { case RangeEndPoints.Inclusive: if (value < lowerBound || value > upperBound) { throw new ArgumentOutOfRangeException( paramName, $"The {paramName} is not within the specified range [{lowerBound}, {upperBound}]. Value = {value}."); } break; case RangeEndPoints.LowerExclusive: if (value <= lowerBound || value > upperBound) { throw new ArgumentOutOfRangeException( paramName, $"The {paramName} is not within the specified range ({lowerBound}, {upperBound}]. Value = {value}."); } break; case RangeEndPoints.UpperExclusive: if (value < lowerBound || value >= upperBound) { throw new ArgumentOutOfRangeException( paramName, $"The {paramName} is not within the specified range [{lowerBound}, {upperBound}). Value = {value}."); } break; case RangeEndPoints.Exclusive: if (value <= lowerBound || value >= upperBound) { throw new ArgumentOutOfRangeException( paramName, $"The {paramName} is not within the specified range ({lowerBound}, {upperBound}). Value = {value}."); } break; } }