System.Linq.Expressions.IndexExpression.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 @object, IEnumerable arguments ) : IndexExpression
@object Expression
arguments IEnumerable The property of the result.
return IndexExpression
        public IndexExpression Update(Expression @object, IEnumerable<Expression> arguments)
        {
            if (@object == Object && arguments == Arguments)
            {
                return this;
            }
            return Expression.MakeIndex(@object, Indexer, arguments);
        }

Usage Example

        /// <summary>
        /// Visits an index expression with the specified <paramref name="isLval"/> behavior.
        /// See <see cref="VisitIndex(IndexExpression)"/> for more information about visitor behavior.
        /// </summary>
        /// <param name="node">The index expression to visit.</param>
        /// <param name="isLval">Indicates whether the index expression occurs in an assignment target position.</param>
        /// <returns>The result of visiting the index expression.</returns>
        protected virtual Expression VisitIndex(IndexExpression node, bool isLval)
        {
            var @object = isLval ? VisitLval(node.Object) : Visit(node.Object);

            if (node.Indexer != null)
            {
                var indexParameters = node.Indexer.GetIndexParameters();

                var arguments = VisitArguments(node.Arguments, indexParameters);

                return(node.Update(@object, arguments));
            }
            else
            {
                return(node.Update(@object, Visit(node.Arguments)));
            }
        }