System.Linq.Expressions.LoopExpression.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 ( LabelTarget breakLabel, LabelTarget continueLabel, Expression body ) : LoopExpression
breakLabel LabelTarget The property of the result.
continueLabel LabelTarget The property of the result.
body Expression The property of the result.
return LoopExpression
        public LoopExpression Update(LabelTarget breakLabel, LabelTarget continueLabel, Expression body)
        {
            if (breakLabel == BreakLabel && continueLabel == ContinueLabel && body == Body)
            {
                return this;
            }
            return Expression.Loop(body, breakLabel, continueLabel);
        }
    }

Usage Example

Example #1
0
        /// <summary>
        ///     Visits the children of the <see cref="LoopExpression" />.
        /// </summary>
        /// <param name="node">The expression to visit.</param>
        /// <returns>
        ///     The modified expression, if it or any subexpression was modified;
        ///     otherwise, returns the original expression.
        /// </returns>
        protected internal virtual Expression VisitLoop(LoopExpression node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            return(node.Update(VisitLabelTarget(node.BreakLabel), VisitLabelTarget(node.ContinueLabel), Visit(node.Body)));
        }
All Usage Examples Of System.Linq.Expressions.LoopExpression::Update