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

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

Reduces the 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()
        {
            if (CanReduce)
            {
                switch (Operand.NodeType)
                {
                    case ExpressionType.Index:
                        return ReduceIndex();
                    case ExpressionType.MemberAccess:
                        return ReduceMember();
                    default:
                        Debug.Assert(Operand.NodeType == ExpressionType.Parameter);
                        return ReduceVariable();
                }
            }
            return this;
        }

Usage Example

Пример #1
0
            protected override Expression VisitUnary(UnaryExpression 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.VisitUnary(node);
            }