mscorlib(4.0.0.0) API with additions
ListInitExpression.cs
3 using System.Diagnostics;
4 
6 {
8  [DebuggerTypeProxy(typeof(ListInitExpressionProxy))]
9  [global::__DynamicallyInvokable]
10  public sealed class ListInitExpression : Expression
11  {
12  private readonly NewExpression _newExpression;
13 
14  private readonly ReadOnlyCollection<ElementInit> _initializers;
15 
18  [global::__DynamicallyInvokable]
19  public sealed override ExpressionType NodeType
20  {
21  [global::__DynamicallyInvokable]
22  get
23  {
24  return ExpressionType.ListInit;
25  }
26  }
27 
30  [global::__DynamicallyInvokable]
31  public sealed override Type Type
32  {
33  [global::__DynamicallyInvokable]
34  get
35  {
36  return _newExpression.Type;
37  }
38  }
39 
42  [global::__DynamicallyInvokable]
43  public override bool CanReduce
44  {
45  [global::__DynamicallyInvokable]
46  get
47  {
48  return true;
49  }
50  }
51 
54  [global::__DynamicallyInvokable]
56  {
57  [global::__DynamicallyInvokable]
58  get
59  {
60  return _newExpression;
61  }
62  }
63 
66  [global::__DynamicallyInvokable]
68  {
69  [global::__DynamicallyInvokable]
70  get
71  {
72  return _initializers;
73  }
74  }
75 
76  internal ListInitExpression(NewExpression newExpression, ReadOnlyCollection<ElementInit> initializers)
77  {
78  _newExpression = newExpression;
79  _initializers = initializers;
80  }
81 
82  protected internal override Expression Accept(ExpressionVisitor visitor)
83  {
84  return visitor.VisitListInit(this);
85  }
86 
89  [global::__DynamicallyInvokable]
90  public override Expression Reduce()
91  {
92  return MemberInitExpression.ReduceListInit(_newExpression, _initializers, keepOnStack: true);
93  }
94 
99  [global::__DynamicallyInvokable]
101  {
102  if (newExpression == NewExpression && initializers == Initializers)
103  {
104  return this;
105  }
106  return Expression.ListInit(newExpression, initializers);
107  }
108  }
109 }
ListInitExpression Update(NewExpression newExpression, IEnumerable< ElementInit > initializers)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...
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.
sealed override ExpressionType NodeType
Returns the node type of this T:System.Linq.Expressions.Expression.
Definition: __Canon.cs:3
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Definition: IEnumerable.cs:9
Provides the base class from which the classes that represent expression tree nodes are derived....
Definition: Expression.cs:17
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
Represents a constructor call that has a collection initializer.
ExpressionType
Describes the node types for the nodes of an expression tree.
ReadOnlyCollection< ElementInit > Initializers
Gets the element initializers that are used to initialize a collection.
override bool CanReduce
Gets a value that indicates whether the expression tree node can be reduced.
override Expression Reduce()
Reduces the binary expression node to a simpler expression.