コード例 #1
0
        public virtual Expression VisitBinaryExpression(BinaryExpression expression)
        {
            this.Visit(expression.Left);
            this.Visit(expression.Right);

            return expression;
        }
コード例 #2
0
        public virtual Ast.Expression VisitBinaryExpression(Ast.BinaryExpression expression)
        {
            this.Visit(expression.Left);
            this.Visit(expression.Right);

            return(expression);
        }
コード例 #3
0
        public override LinqExtender.Ast.Expression VisitBinaryExpression(LinqExtender.Ast.BinaryExpression expression)
        {
            this.Visit(expression.Left);
            this.Write(GetBinaryOperator(expression.Operator));
            this.Visit(expression.Right);

            return(expression);
        }
コード例 #4
0
ファイル: ExpressionVisitor.cs プロジェクト: pyerbiz/witsml
        /// <summary>
        /// Visits a <see cref="Ast.BinaryExpression"/>
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <returns>An <see cref="Ast.Expression"/></returns>
        public virtual Ast.Expression VisitBinaryExpression(Ast.BinaryExpression expression)
        {
            var left  = expression.Left as Ast.MemberExpression;
            var right = expression.Right as Ast.LiteralExpression;

            if (left != null && expression.Operator == BinaryOperator.Equal && right != null)
            {
                var property = left.Member.MemberInfo as PropertyInfo;

                if (property != null)
                {
                    SetPropertyValue(property, right.Value);
                }
            }

            this.Visit(expression.Left);
            this.Visit(expression.Right);

            return(expression);
        }
コード例 #5
0
        internal override void ExecuteQuery(IBucket bucket, IModifiableCollection <T> items)
        {
            var fluentBucket    = FluentBucket.As(bucket);
            var expressionStack = new Stack <Ast.Expression>();

            var blockExpression = new Ast.BlockExpression();

            blockExpression.Expressions.Add(new Ast.TypeExpression(typeof(T)));

            if (fluentBucket.IsDirty)
            {
                var lambda = new Ast.LambdaExpression(typeof(T));

                fluentBucket.ExpressionTree
                .DescribeContainerAs(expressionStack)
                .Root((stack, operatorType) =>
                {
                    var logical = new Ast.LogicalExpression(operatorType);

                    var left = stack.Pop();

                    MarkAsChild(left);

                    logical.Left = left;
                    stack.Push(logical);
                })
                .EachLeaf((stack, item) =>
                {
                    var binary = new Ast.BinaryExpression(item.Operator)
                    {
                        Left  = new Ast.MemberExpression(item),
                        Right = new Ast.LiteralExpression(item.PropertyType, item.Value)
                    };

                    stack.Push(binary);
                })
                .End(stack =>
                {
                    var binary = stack.Pop();

                    if (stack.Count > 0 &&
                        stack.Peek().CodeType == CodeType.LogicalExpression)
                    {
                        var logical   = stack.Pop() as Ast.LogicalExpression;
                        logical.Right = binary;

                        // nested.
                        if (Peek(stack) as Ast.LogicalExpression != null)
                        {
                            MarkAsChild(logical);
                        }

                        stack.Push(logical);
                    }
                    else
                    {
                        stack.Push(binary);
                    }
                })
                .Execute();

                lambda.Body = expressionStack.Pop();
                blockExpression.Expressions.Add(lambda);
            }

            fluentBucket.Entity.OrderBy.IfUsed(() =>
                                               fluentBucket.Entity.OrderBy.ForEach.Process((member, asending) => {
                blockExpression.Expressions.Add(new Ast.OrderbyExpression(member, asending));
            }));

            fluentBucket.Method.ForEach((method) =>
            {
                blockExpression.Expressions.Add(new Ast.MethodCallExpression(method));
            });

            items.AddRange(Context.Execute(blockExpression));
        }