Ejemplo n.º 1
0
        public static bool IsBetweenDecimalExpression(IScriptCallContext context, double lower, NumericLimitType op1, double value, NumericLimitType op2, double upper)
        {
            double tolerance = (upper - lower) * APPROX_TOL;

            bool result = true;

            switch (op1)
            {
            case NumericLimitType.Exclude:
                result &= (value > lower);
                break;

            case NumericLimitType.Include:
                result &= (value >= lower);
                break;

            case NumericLimitType.Approx:
                result &= (value > (lower - tolerance));
                break;

            default:
                throw new NotImplementedException();
            }
            switch (op1)
            {
            case NumericLimitType.Exclude:
                result &= (value < upper);
                break;

            case NumericLimitType.Include:
                result &= (value <= upper);
                break;

            case NumericLimitType.Approx:
                result &= (value < (upper + tolerance));
                break;

            default:
                throw new NotImplementedException();
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static bool IsBetweenTimespanExpression(IScriptCallContext context, TimeSpan lower, NumericLimitType op1, TimeSpan value, NumericLimitType op2, TimeSpan upper)
        {
            long tolerance = APPROX_TOL_TS;

            bool result = true;

            switch (op1)
            {
            case NumericLimitType.Exclude:
                result = (value > lower);
                break;

            case NumericLimitType.Include:
                result = (value >= lower);
                break;

            case NumericLimitType.Approx:
                result = (value.Ticks > (lower.Ticks - tolerance));
                break;

            default:
                throw new NotImplementedException();
            }
            switch (op1)
            {
            case NumericLimitType.Exclude:
                result &= (value < upper);
                break;

            case NumericLimitType.Include:
                result &= (value <= upper);
                break;

            case NumericLimitType.Approx:
                result &= (value.Ticks < (upper.Ticks + tolerance));
                break;

            default:
                throw new NotImplementedException();
            }

            return(result);
        }
Ejemplo n.º 3
0
        public static bool IsBetweenIntegerExpression(IScriptCallContext context, long lower, NumericLimitType op1, long value, NumericLimitType op2, long upper)
        {
            bool result = true;

            switch (op1)
            {
            case NumericLimitType.Exclude:
                result &= (value > lower);
                break;

            case NumericLimitType.Include:
            case NumericLimitType.Approx:
                result &= (value >= lower);
                break;

            default:
                throw new NotImplementedException();
            }
            switch (op1)
            {
            case NumericLimitType.Exclude:
                result &= (value < upper);
                break;

            case NumericLimitType.Include:
            case NumericLimitType.Approx:
                result &= (value <= upper);
                break;

            default:
                throw new NotImplementedException();
            }

            return(result);
        }