System.Linq.Expressions.BinaryExpression.Reduce C# (CSharp) Метод

Reduce() публичный Метод

Reduces the binary expression node to a simpler expression. If CanReduce returns true, this should return a valid expression. This method is allowed to return another node which itself must be reduced.
public Reduce ( ) : Expression
Результат Expression
        public override Expression Reduce()
        {
            // Only reduce OpAssignment expressions.
            if (IsOpAssignment(NodeType))
            {
                switch (Left.NodeType)
                {
                    case ExpressionType.MemberAccess:
                        return ReduceMember();

                    case ExpressionType.Index:
                        return ReduceIndex();

                    default:
                        return ReduceVariable();
                }
            }
            return this;
        }

Usage Example

Пример #1
0
            protected override Expression VisitBinary(BinaryExpression node)
            {
                // NB: This reduces assignment operators so that the stack spiller doesn't have to worry about it.
                if (node.CanReduce)
                {
                    return node.Reduce();
                }

                return base.VisitBinary(node);
            }