/// <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 <float> > exp, float val, float bound1, float 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(), MathsFloatExtensions.GetLowerBound(bound1, bound2, allowEitherOrder), MathsFloatExtensions.GetUpperBound(bound1, bound2, allowEitherOrder) ) ) ); }
public float GetUpperBound(float min, float max, bool allowEitherOrder) { return(MathsFloatExtensions.GetUpperBound(min, max, allowEitherOrder)); }