/// <summary> /// Ensures the expression and corresponding value evaluates to between the specified values /// </summary> /// <param name="exp">The exp.</param> /// <param name="val">The value.</param> /// <param name="bound1">The bound1.</param> /// <param name="bound2">The bound2.</param> /// <param name="allowEitherOrder">if set to <c>true</c> [allow either order].</param> /// <param name="boundsType">Type of the bounds.</param> /// <exception cref="ArgumentOutOfRangeException"></exception> /// <exception cref="System.ArgumentOutOfRangeException"></exception> public static void IsBetween(Expression <Func <int> > exp, int val, int bound1, int bound2, bool allowEitherOrder, IsBetweenBoundsType boundsType) { if (val.IsBetween(bound1, bound2, allowEitherOrder, boundsType)) { return; } var memberName = ExpressionExtensions.GetMemberName(exp); throw new ArgumentOutOfRangeException( memberName, val, string.Format("{0} must be {1}", memberName, string.Format(boundsType.GetLimitDescriptionFormat(), MathsInt32Extensions.GetLowerBound(bound1, bound2, allowEitherOrder), MathsInt32Extensions.GetUpperBound(bound1, bound2, allowEitherOrder) ) ) ); }
public int GetUpperBound(int min, int max, bool allowEitherOrder) { return(MathsInt32Extensions.GetUpperBound(min, max, allowEitherOrder)); }