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);
        }
예제 #3
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);
        }
            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();
            }