Esempio n. 1
0
        public override BaseLogicalExpression ToExpression()
        {
            BaseLogicalExpression expr = null;

            // Check if we need to change value type
            object parsedValue = Value;

            if (int.TryParse((string)parsedValue, out int intValue))
            {
                parsedValue = intValue;
            }
            else
            {
                // Strip single quotes from value
                parsedValue = Value.Replace("'", "");
            }

            switch (RelationalOperator)
            {
            case RelationalOperator.EQUAL:
                expr = new EqExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.NOT_EQUAL:
                expr = new NeqExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.GREATER_EQUAL:
                expr = new GteExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.LESS_EQUAL:
                expr = new LteExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.GREATER:
                expr = new GtExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.LESS:
                expr = new LtExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.LIKE:
            case RelationalOperator.IS:
                throw new NotSupportedException("Operation not supported");
            }

            return(expr);
        }
Esempio n. 2
0
        public Expr ToExpr()
        {
            Expr expr = null;

            for (int i = 0; i < LogicalTerms.Count; i += 2)
            {
                BaseLogicalExpression left = LogicalTerms[i].ToExpression();

                if (i + 1 >= LogicalTerms.Count)
                {
                    // return just the first term
                    expr = new Expr(left);
                    break;
                }

                BaseLogicalExpression right = LogicalTerms[i + 1].ToExpression();

                if (i < LogicalOperators.Count)
                {
                    LogicalOperator op = LogicalOperators.ElementAt(i);
                    switch (op)
                    {
                    case LogicalOperator.AND:
                        expr = new Expr(new LogicalExpressionGroup(left, Expressions.LogicalOperator.AND, right));
                        break;

                    case LogicalOperator.OR:
                        expr = new Expr(new LogicalExpressionGroup(left, Expressions.LogicalOperator.OR, right));
                        break;
                    }
                }
                else
                {
                    // This is probably invalid
                    throw new InvalidOperationException();
                }
            }

            return(expr);
        }
 /// <summary>
 /// Initialize a new instance of SelectArgument
 /// </summary>
 /// <param name="ExpressionGroup"></param>
 public SelectArgument(BaseLogicalExpression Expression)
 {
     this.Expression = Expression;
 }
Esempio n. 4
0
 /// <summary>
 /// Initialize a new instance of Match
 /// </summary>
 /// <param name="Expression">Expression to be evalueted</param>
 public MatchOperator(BaseLogicalExpression Expression)
 {
     this.Expression = Expression;
     FieldsToMatch   = new Dictionary <string, object>();
 }