Exemplo n.º 1
0
        /// <summary>
        /// Adds to the lambda expression a numerical "within range" test with the queryable value.
        /// The range numbers don't need to be in numeric order.</summary>
        /// <param name="patternNumber1">Number with which to compare queryable value</param>
        /// <param name="patternNumber2">Number with which to compare queryable value</param>
        /// <param name="isReplacePattern">Whether this match should be used for a subsequent replace operation</param>
        public void AddNumberValueBetweenExpression(Double patternNumber1, Double patternNumber2, bool isReplacePattern)
        {
            if (isReplacePattern)
            {
                MatchPattern = new NumberReplaceQueryPattern(patternNumber1, patternNumber2);
            }

            // Create expression which tests:
            //
            // (PropertyValueConvertibleToDouble() == true) &&
            // (((num1 <= num2) && (num1 <= propertyValue) && (propertyValue <= num2)) ||
            //  ((num2 <= num1) && (num2 <= propertyValue) && (propertyValue <= num1)))
            //
            MethodCallExpression convertToDouble = GetConvertToDoubleExpression();
            ConstantExpression   num1Exp         = Expression.Constant(patternNumber1);
            ConstantExpression   num2Exp         = Expression.Constant(patternNumber2);

            AddExpression(
                Expression.AndAlso(
                    GetValueIsConvertibleToDoubleExpression(),
                    Expression.Or(
                        Expression.AndAlso(
                            Expression.LessThanOrEqual(num1Exp, num2Exp),
                            Expression.AndAlso(
                                Expression.LessThanOrEqual(num1Exp, convertToDouble),
                                Expression.LessThanOrEqual(convertToDouble, num2Exp))),
                        Expression.AndAlso(
                            Expression.LessThanOrEqual(num2Exp, num1Exp),
                            Expression.AndAlso(
                                Expression.LessThanOrEqual(num2Exp, convertToDouble),
                                Expression.LessThanOrEqual(convertToDouble, num1Exp))))));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds to the lambda expression a numerical "greater than" test with the queryable value</summary>
        /// <param name="patternNumber">Number with which to compare queryable value</param>
        /// <param name="isReplacePattern">Whether this match should be used for a subsequent replace operation</param>
        public void AddNumberValueGreaterExpression(Double patternNumber, bool isReplacePattern)
        {
            if (isReplacePattern)
            {
                MatchPattern = new NumberReplaceQueryPattern(patternNumber);
            }

            AddExpression(
                Expression.AndAlso(
                    GetValueIsConvertibleToDoubleExpression(),
                    Expression.GreaterThan(GetConvertToDoubleExpression(), Expression.Constant(patternNumber))));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds to the lambda expression a numerical "within range" test with the queryable value.
        /// The range numbers don't need to be in numeric order.</summary>
        /// <param name="patternNumber1">Number with which to compare queryable value</param>
        /// <param name="patternNumber2">Number with which to compare queryable value</param>
        /// <param name="isReplacePattern">Whether this match should be used for a subsequent replace operation</param>
        public void AddNumberValueBetweenExpression(Double patternNumber1, Double patternNumber2, bool isReplacePattern)
        {
            if (isReplacePattern)
                MatchPattern = new NumberReplaceQueryPattern(patternNumber1, patternNumber2);

            // Create expression which tests:
            //
            // (PropertyValueConvertibleToDouble() == true) &&
            // (((num1 <= num2) && (num1 <= propertyValue) && (propertyValue <= num2)) || 
            //  ((num2 <= num1) && (num2 <= propertyValue) && (propertyValue <= num1)))
            //
            MethodCallExpression convertToDouble = GetConvertToDoubleExpression();
            ConstantExpression num1Exp = Expression.Constant(patternNumber1);
            ConstantExpression num2Exp = Expression.Constant(patternNumber2);
            AddExpression(
                Expression.AndAlso(
                    GetValueIsConvertibleToDoubleExpression(),
                    Expression.Or(
                        Expression.AndAlso(
                            Expression.LessThanOrEqual(num1Exp, num2Exp),
                            Expression.AndAlso(
                                Expression.LessThanOrEqual(num1Exp, convertToDouble),
                                Expression.LessThanOrEqual(convertToDouble, num2Exp))),
                        Expression.AndAlso(
                            Expression.LessThanOrEqual(num2Exp, num1Exp),
                            Expression.AndAlso(
                                Expression.LessThanOrEqual(num2Exp, convertToDouble),
                                Expression.LessThanOrEqual(convertToDouble, num1Exp))))));

        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds to the lambda expression a numerical "greater than" test with the queryable value</summary>
        /// <param name="patternNumber">Number with which to compare queryable value</param>
        /// <param name="isReplacePattern">Whether this match should be used for a subsequent replace operation</param>
        public void AddNumberValueGreaterExpression(Double patternNumber, bool isReplacePattern)
        {
            if (isReplacePattern)
                MatchPattern = new NumberReplaceQueryPattern(patternNumber);

            AddExpression(
                Expression.AndAlso(
                    GetValueIsConvertibleToDoubleExpression(),
                    Expression.GreaterThan(GetConvertToDoubleExpression(), Expression.Constant(patternNumber))));
        }