Update() 공개 메소드

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 ( NewExpression newExpression, IEnumerable bindings ) : MemberInitExpression
newExpression NewExpression The property of the result.
bindings IEnumerable The property of the result.
리턴 MemberInitExpression
예제 #1
0
 /// <summary>
 /// Visits the children of the <see cref="MemberInitExpression"/>.
 /// </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 VisitMemberInit(MemberInitExpression node)
 {
     return(node.Update(
                VisitAndConvert(node.NewExpression, nameof(VisitMemberInit)),
                Visit(node.Bindings, VisitMemberBinding)
                ));
 }
예제 #2
0
 protected override Expression VisitMemberInit(MemberInitExpression node)
 {
     // If we here, than eval the whole block failed, don't touch constructor!
     _allowEval = false;
     var newExpr = VisitAndConvert(node.NewExpression, "VisitMemberInit");
     _allowEval = true;
     // ReSharper disable once AssignNullToNotNullAttribute
     return node.Update(newExpr, Visit(node.Bindings, VisitMemberBinding));
 }
예제 #3
0
        protected override ExpressionTree VisitMemberInit(MemberInitExpression node)
        {
            CheckChildrenCount(1 + node.Bindings.Count);

            var n = (NewExpression)ExtractChildExpression(0);
            var b = ExtractChildBindings(1, node.Bindings.Count);

            var expression = node.Update(n, b);

            return(CreateExpressionTree(expression));
        }
예제 #4
0
        /// <summary>
        ///     Visits the children of the <see cref="MemberInitExpression" />.
        /// </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 VisitMemberInit(MemberInitExpression node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            return(node.Update
                   (
                       VisitAndConvert(node.NewExpression, nameof(VisitMemberInit)),
                       Visit(node.Bindings, VisitMemberBinding)
                   ));
        }
			protected override Expression VisitMemberInit(MemberInitExpression node)
			{
				var visitAndConvert = VisitAndConvert(node.NewExpression, "VisitMemberInit");
				var readOnlyCollection = Visit(node.Bindings, VisitMemberBinding);
				return node.Update(visitAndConvert, readOnlyCollection);
			}
 protected internal virtual Expression VisitMemberInit(MemberInitExpression node)
 {
     return(node.Update(this.VisitAndConvert <NewExpression>(node.NewExpression, "VisitMemberInit"), Visit <MemberBinding>(node.Bindings, new Func <MemberBinding, MemberBinding>(this.VisitMemberBinding))));
 }
예제 #7
0
 // 其他信息: 从“VisitMemberInit”调用时,重写“System.Linq.Expressions.NewExpression”类型的节点必须返回相同类型的非 null 值。或者,重写并更改“VisitMemberInit”,以便不访问此类型的子级。
 protected override Expression VisitMemberInit(MemberInitExpression node)
 {
     NewExpression newExpr = this.Visit(node.NewExpression) as NewExpression;
     var bindings = ExpressionVisitor.Visit(node.Bindings, this.VisitMemberBinding);
     return node.Update(newExpr ?? node.NewExpression, bindings);
 }