private Token ParseMethodCallExpression(MethodCallExpression methodCallExpression)
            {
                var visitor1 = new MethodCallExpressionVisitor(Context);

                visitor1.Visit(methodCallExpression);
                return(visitor1.Token);
            }
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            var visitor = new MethodCallExpressionVisitor(Context);

            visitor.Visit(node);
            Token = visitor.Token;
            return(node);
        }
        protected override Expression VisitUnary(UnaryExpression node)
        {
            if (node.NodeType != ExpressionType.Not)
            {
                throw new Exception();
            }
            var operand = node.Operand;
            ExpressionVisitorBase base2 = null;

            if (operand.NodeType == ExpressionType.Call)
            {
                base2 = new MethodCallExpressionVisitor(Context);
            }
            else
            {
                if (operand.NodeType != ExpressionType.MemberAccess)
                {
                    throw new Exception();
                }
                base2 = new MemberExpressionVisitor(Context);
            }
            base2.Visit(node);
            Token = base2.Token;
            if (Token.IsBool())
            {
                Token = Token.Create(!(bool)Token.Object);
                return(node);
            }
            if (Token.Type != TokenType.Column)
            {
                throw new Exception();
            }
            var condition1 = new Condition
            {
                CompareType = CompareType.Not,
                Left        = Token
            };

            Token = Token.Create(condition1);
            return(node);
        }
Exemple #4
0
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            var visitor = new MethodCallExpressionVisitor(Context);

            visitor.Visit(node);
            var type = visitor.Token.Type;

            if (type != TokenType.Column)
            {
                if (type == TokenType.Condition)
                {
                    throw new Exception();
                }
                var obj2 = visitor.Token.Object;
                while (_memberInfos.Count > 0)
                {
                    obj2 = GetValue((MemberExpression)_memberInfos.Pop(), obj2);
                }
                Token = Token.Create(obj2);
                return(node);
            }
            Token = visitor.Token;
            var column = Token.Column;

            while (_memberInfos.Count > 0)
            {
                var expression = _memberInfos.Pop();
                if (expression.NodeType != ExpressionType.MemberAccess)
                {
                    throw new Exception();
                }
                var member = ((MemberExpression)expression).Member;
                column.Converters.Push(new ColumnConverter(member, new List <object>()));
            }
            return(node);
        }
Exemple #5
0
        public override Expression Visit(Expression node)
        {
            ExpressionVisitorBase base2 = null;

            if (node.NodeType == ExpressionType.Quote)
            {
                node = ((UnaryExpression)node).Operand;
            }
            if (node.NodeType == ExpressionType.Lambda)
            {
                node = ((LambdaExpression)node).Body;
            }
            if (node.NodeType == ExpressionType.Call)
            {
                base2 = new MethodCallExpressionVisitor(Context);
            }
            else
            {
                base2 = new PropertyFieldExpressionVisitor(Context);
            }
            base2.Visit(node);
            Token = base2.Token;
            return(node);
        }
            private Token ParseNotExpression(UnaryExpression unaryExpression)
            {
                var operand = unaryExpression.Operand;

                if (operand is MemberExpression)
                {
                    var visitor = new MemberExpressionVisitor(Context);
                    visitor.Visit(operand);
                    var type = visitor.Token.Type;
                    if (type != TokenType.Column)
                    {
                        if (type != TokenType.Object)
                        {
                            throw new Exception();
                        }
                        if (!visitor.Token.IsBool())
                        {
                            throw new Exception("不支持");
                        }
                        return(Token.Create(!(bool)visitor.Token.Object));
                    }
                    if ((operand.Type == typeof(bool)) || (operand.Type == typeof(bool?)))
                    {
                        var condition1 = new Condition
                        {
                            CompareType = CompareType.Equal,
                            Left        = Token.Create(1),
                            Right       = Token.Create(1)
                        };
                        return(Token.Create(condition1));
                    }
                    var condition2 = new Condition
                    {
                        Left        = visitor.Token,
                        CompareType = CompareType.Not
                    };
                    return(Token.Create(condition2));
                }
                if (!(operand is MethodCallExpression))
                {
                    throw new Exception("不支持");
                }
                var visitor1 = new MethodCallExpressionVisitor(Context);

                visitor1.Visit(operand);
                var token = visitor1.Token;

                switch (token.Type)
                {
                case TokenType.Column:
                {
                    var condition3 = new Condition
                    {
                        Left        = token,
                        CompareType = CompareType.Not
                    };
                    return(Token.Create(condition3));
                }

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

                case TokenType.Condition:
                {
                    var condition4 = new Condition
                    {
                        Left        = Token.Create(token.Condition),
                        CompareType = CompareType.Not
                    };
                    return(Token.Create(condition4));
                }
                }
                throw new Exception();
            }