System.Linq.Expressions.SwitchExpression.Update C# (CSharp) Method

Update() public method

Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
public Update ( Expression switchValue, IEnumerable cases, Expression defaultBody ) : SwitchExpression
switchValue Expression The property of the result.
cases IEnumerable The property of the result.
defaultBody Expression The property of the result.
return SwitchExpression
        public SwitchExpression Update(Expression switchValue, IEnumerable<SwitchCase> cases, Expression defaultBody)
        {
            if (switchValue == SwitchValue && cases == Cases && defaultBody == DefaultBody)
            {
                return this;
            }
            return Expression.Switch(Type, switchValue, defaultBody, Comparison, cases);
        }
    }

Usage Example

コード例 #1
0
        private Expression VisitSwitchExtracted(SwitchExpression node)
        {
            var visitedSwitchValue = node.SwitchValue;
            var visitedCases       = Visit(node.Cases, VisitSwitchCase);
            var visitedDefaultBody = Visit(node.DefaultBody);
            var updated            = node.Update(visitedSwitchValue, visitedCases, visitedDefaultBody);

            return(ValidateSwitch(node, updated));
        }
All Usage Examples Of System.Linq.Expressions.SwitchExpression::Update