10 [DebuggerTypeProxy(typeof(MemberInitExpressionProxy))]
11 [global::__DynamicallyInvokable]
20 [global::__DynamicallyInvokable]
23 [global::__DynamicallyInvokable]
26 return _newExpression.Type;
32 [global::__DynamicallyInvokable]
35 [global::__DynamicallyInvokable]
44 [global::__DynamicallyInvokable]
47 [global::__DynamicallyInvokable]
56 [global::__DynamicallyInvokable]
59 [global::__DynamicallyInvokable]
62 return _newExpression;
68 [global::__DynamicallyInvokable]
71 [global::__DynamicallyInvokable]
80 _newExpression = newExpression;
84 protected internal override Expression Accept(ExpressionVisitor visitor)
86 return visitor.VisitMemberInit(
this);
91 [global::__DynamicallyInvokable]
94 return ReduceMemberInit(_newExpression, _bindings, keepOnStack:
true);
100 int count = bindings.
Count;
102 array[0] =
Expression.Assign(parameterExpression, objExpression);
103 for (
int i = 0; i < count; i++)
105 array[i + 1] = ReduceMemberBinding(parameterExpression, bindings[i]);
107 array[count + 1] = (keepOnStack ? ((Expression)parameterExpression) : ((Expression)Expression.Empty()));
108 return Expression.Block(
new TrueReadOnlyCollection<Expression>(array));
113 ParameterExpression parameterExpression = Expression.Variable(listExpression.Type,
null);
114 int count = initializers.
Count;
115 Expression[] array =
new Expression[count + 2];
116 array[0] = Expression.Assign(parameterExpression, listExpression);
117 for (
int i = 0; i < count; i++)
119 ElementInit elementInit = initializers[i];
120 array[i + 1] = Expression.Call(parameterExpression, elementInit.AddMethod, elementInit.Arguments);
122 array[count + 1] = (keepOnStack ? ((Expression)parameterExpression) : ((Expression)Expression.Empty()));
123 return Expression.Block(
new TrueReadOnlyCollection<Expression>(array));
126 internal static Expression ReduceMemberBinding(ParameterExpression objVar,
MemberBinding binding)
128 MemberExpression memberExpression = Expression.MakeMemberAccess(objVar, binding.Member);
129 switch (binding.BindingType)
132 return Expression.Assign(memberExpression, ((MemberAssignment)binding).Expression);
134 return ReduceListInit(memberExpression, ((MemberListBinding)binding).Initializers, keepOnStack:
false);
136 return ReduceMemberInit(memberExpression, ((MemberMemberBinding)binding).
Bindings, keepOnStack:
false);
138 throw ContractUtils.Unreachable;
146 [global::__DynamicallyInvokable]
153 return Expression.MemberInit(newExpression, bindings);
ReadOnlyCollection< MemberBinding > Bindings
Gets the bindings that describe how to initialize the members of the newly created object.
Provides the base class for a generic read-only collection.
Represents a constructor call.
Represents calling a constructor and initializing one or more members of the new object.
int Count
Gets the number of elements contained in the T:System.Collections.ObjectModel.ReadOnlyCollection`1 in...
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Provides the base class from which the classes that represent expression tree nodes are derived....
MemberBindingType
Describes the binding types that are used in T:System.Linq.Expressions.MemberInitExpression objects.
Represents type declarations: class types, interface types, array types, value types,...
override bool CanReduce
Gets a value that indicates whether the expression tree node can be reduced.
override Expression Reduce()
Reduces the T:System.Linq.Expressions.MemberInitExpression to a simpler expression.
Represents a named parameter expression.
ExpressionType
Describes the node types for the nodes of an expression tree.
MemberInitExpression Update(NewExpression newExpression, IEnumerable< MemberBinding > bindings)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...
A binding that represents recursively initializing members of a member.
sealed override ExpressionType NodeType
Returns the node type of this Expression. Extension nodes should return F:System.Linq....