static void AnalyzeBinaryExpression(SyntaxNodeAnalysisContext nodeContext)
        {
            var node    = nodeContext.Node as BinaryExpressionSyntax;
            var visitor = new BinaryExpressionVisitor(nodeContext);

            visitor.Visit(node);
        }
 protected override Expression VisitBinary(BinaryExpression node)
 {
     BinaryExpressionVisitor visitor = new BinaryExpressionVisitor(Context);
     visitor.Visit(node);
     Token = visitor.Token;
     return node;
 }
            Token VisitBinaryNode(Expression node)
            {
                BinaryExpressionVisitor visitor = new BinaryExpressionVisitor(Context);

                visitor.Visit(node);
                return(visitor.Token);
            }
Exemple #4
0
    static void Main(string[] args)
    {
        Expression <Func <double, bool> > predicate = x => x > 3 && x > 4;
        var visitor = new BinaryExpressionVisitor();

        predicate = (Expression <Func <double, bool> >)visitor.Visit(predicate);
    }
            private Token VisitBinaryNode(Expression node)
            {
                if (node.NodeType == ExpressionType.Not)
                {
                    var token = VisitBinaryNode(((UnaryExpression)node).Operand);
                    switch (token.Type)
                    {
                    case TokenType.Column:
                    {
                        var condition1 = new Condition
                        {
                            Left        = token,
                            CompareType = CompareType.Not
                        };
                        return(Token.Create(condition1));
                    }

                    case TokenType.Object:
                        return(Token.Create(!(bool)token.Object));

                    case TokenType.Condition:
                        token.Condition.Right = Token.Create(0);
                        return(token);
                    }
                    throw new Exception();
                }
                if (node is MemberExpression)
                {
                    var visitor1 = new MemberExpressionVisitor(Context);
                    visitor1.Visit(node);
                    var token2 = visitor1.Token;
                    var type   = token2.Type;
                    if (type != TokenType.Column)
                    {
                        if (type != TokenType.Object)
                        {
                            throw new Exception();
                        }
                        return(token2);
                    }
                    if (TypeHelper.GetUnderlyingType(token2.Column.DataType) != ReflectorConsts.BoolType)
                    {
                        throw new Exception();
                    }
                    var token3     = token2;
                    var token4     = Token.Create(1);
                    var condition2 = new Condition
                    {
                        CompareType = CompareType.Equal,
                        Left        = token3,
                        Right       = token4
                    };
                    return(Token.Create(condition2));
                }
                var visitor2 = new BinaryExpressionVisitor(Context);

                visitor2.Visit(node);
                return(visitor2.Token);
            }
            protected override Expression VisitBinary(BinaryExpression node)
            {
                BinaryExpressionVisitor visitor = new BinaryExpressionVisitor(Context);

                visitor.Visit(node.Left);
                Token = visitor.Token;
                return(node);
            }
Exemple #7
0
        static void AnalyzeBinaryExpression(OperationAnalysisContext nodeContext)
        {
            var node = (IBinaryOperation)nodeContext.Operation;

            if (node.OperatorKind == BinaryOperatorKind.Add)
            {
                var visitor = new BinaryExpressionVisitor(nodeContext);
                visitor.Visit(node);
            }
        }
        static void AnalyzeBinaryExpression(SyntaxNodeAnalysisContext nodeContext)
        {
            if (nodeContext.IsFromGeneratedCode())
            {
                return;
            }
            var node    = nodeContext.Node as BinaryExpressionSyntax;
            var visitor = new BinaryExpressionVisitor(nodeContext);

            visitor.Visit(node);
        }
 static void AnalyzeBinaryExpression(SyntaxNodeAnalysisContext nodeContext)
 {
     var node = nodeContext.Node as BinaryExpressionSyntax;
     var visitor = new BinaryExpressionVisitor(nodeContext);
     visitor.Visit(node);
 }
 Token VisitBinaryNode(Expression node)
 {
     BinaryExpressionVisitor visitor = new BinaryExpressionVisitor(Context);
     visitor.Visit(node);
     return visitor.Token;
 }