mscorlib(4.0.0.0) API with additions
NewExpression.cs
3 using System.Diagnostics;
4 using System.Reflection;
5 
7 {
9  [DebuggerTypeProxy(typeof(NewExpressionProxy))]
10  [global::__DynamicallyInvokable]
12  {
13  private readonly ConstructorInfo _constructor;
14 
15  private IList<Expression> _arguments;
16 
17  private readonly ReadOnlyCollection<MemberInfo> _members;
18 
21  [global::__DynamicallyInvokable]
22  public override Type Type
23  {
24  [global::__DynamicallyInvokable]
25  get
26  {
27  return _constructor.DeclaringType;
28  }
29  }
30 
33  [global::__DynamicallyInvokable]
34  public sealed override ExpressionType NodeType
35  {
36  [global::__DynamicallyInvokable]
37  get
38  {
39  return ExpressionType.New;
40  }
41  }
42 
45  [global::__DynamicallyInvokable]
47  {
48  [global::__DynamicallyInvokable]
49  get
50  {
51  return _constructor;
52  }
53  }
54 
57  [global::__DynamicallyInvokable]
59  {
60  [global::__DynamicallyInvokable]
61  get
62  {
63  return Expression.ReturnReadOnly(ref _arguments);
64  }
65  }
66 
69  [global::__DynamicallyInvokable]
71  {
72  [global::__DynamicallyInvokable]
73  get
74  {
75  return _arguments.Count;
76  }
77  }
78 
81  [global::__DynamicallyInvokable]
83  {
84  [global::__DynamicallyInvokable]
85  get
86  {
87  return _members;
88  }
89  }
90 
91  internal NewExpression(ConstructorInfo constructor, IList<Expression> arguments, ReadOnlyCollection<MemberInfo> members)
92  {
93  _constructor = constructor;
94  _arguments = arguments;
95  _members = members;
96  }
97 
101  [global::__DynamicallyInvokable]
102  Expression IArgumentProvider.GetArgument(int index)
103  {
104  return _arguments[index];
105  }
106 
110  [global::__DynamicallyInvokable]
111  protected internal override Expression Accept(ExpressionVisitor visitor)
112  {
113  return visitor.VisitNew(this);
114  }
115 
119  [global::__DynamicallyInvokable]
121  {
122  if (arguments == Arguments)
123  {
124  return this;
125  }
126  if (Members != null)
127  {
128  return Expression.New(Constructor, arguments, Members);
129  }
130  return Expression.New(Constructor, arguments);
131  }
132  }
133 }
ConstructorInfo Constructor
Gets the called constructor.
Represents a constructor call.
Discovers the attributes of a class constructor and provides access to constructor metadata.
Provides an internal interface for accessing the arguments of multiple tree nodes (DynamicExpression,...
Definition: __Canon.cs:3
override Type DeclaringType
Gets the type that declares the current nested type or generic type parameter.
Definition: Type.cs:54
NewExpression Update(IEnumerable< Expression > arguments)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Definition: IEnumerable.cs:9
sealed override ExpressionType NodeType
Returns the node type of this T:System.Linq.Expressions.Expression.
int ArgumentCount
Returns the number of arguments to the expression tree node. You should not use this type....
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
ExpressionType
Describes the node types for the nodes of an expression tree.
Represents a collection of objects that can be individually accessed by index.
Definition: IList.cs:9
int Count
Gets the number of elements contained in the T:System.Collections.Generic.ICollection`1.
Definition: ICollection.cs:15
internal override Expression Accept(ExpressionVisitor visitor)
Dispatches to the specific visit method for this node type. For example, T:System....
ReadOnlyCollection< Expression > Arguments
Gets the arguments to the constructor.
virtual internal Expression VisitNew(NewExpression node)
Visits the children of the T:System.Linq.Expressions.NewExpression.
ReadOnlyCollection< MemberInfo > Members
Gets the members that can retrieve the values of the fields that were initialized with constructor ar...
Represents a visitor or rewriter for expression trees.