mscorlib(4.0.0.0) API with additions
IndexExpression.cs
3 using System.Diagnostics;
4 using System.Reflection;
5 
7 {
9  [DebuggerTypeProxy(typeof(IndexExpressionProxy))]
10  [global::__DynamicallyInvokable]
12  {
13  private readonly Expression _instance;
14 
15  private readonly PropertyInfo _indexer;
16 
17  private IList<Expression> _arguments;
18 
21  [global::__DynamicallyInvokable]
22  public sealed override ExpressionType NodeType
23  {
24  [global::__DynamicallyInvokable]
25  get
26  {
27  return ExpressionType.Index;
28  }
29  }
30 
33  [global::__DynamicallyInvokable]
34  public sealed override Type Type
35  {
36  [global::__DynamicallyInvokable]
37  get
38  {
39  if (_indexer != null)
40  {
41  return _indexer.PropertyType;
42  }
43  return _instance.Type.GetElementType();
44  }
45  }
46 
49  [global::__DynamicallyInvokable]
50  public Expression Object
51  {
52  [global::__DynamicallyInvokable]
53  get
54  {
55  return _instance;
56  }
57  }
58 
61  [global::__DynamicallyInvokable]
62  public PropertyInfo Indexer
63  {
64  [global::__DynamicallyInvokable]
65  get
66  {
67  return _indexer;
68  }
69  }
70 
73  [global::__DynamicallyInvokable]
75  {
76  [global::__DynamicallyInvokable]
77  get
78  {
79  return Expression.ReturnReadOnly(ref _arguments);
80  }
81  }
82 
85  [global::__DynamicallyInvokable]
87  {
88  [global::__DynamicallyInvokable]
89  get
90  {
91  return _arguments.Count;
92  }
93  }
94 
95  internal IndexExpression(Expression instance, PropertyInfo indexer, IList<Expression> arguments)
96  {
97  bool flag = indexer == null;
98  _instance = instance;
99  _indexer = indexer;
100  _arguments = arguments;
101  }
102 
107  [global::__DynamicallyInvokable]
109  {
110  if (@object == Object && arguments == Arguments)
111  {
112  return this;
113  }
114  return Expression.MakeIndex(@object, Indexer, arguments);
115  }
116 
120  [global::__DynamicallyInvokable]
122  {
123  return _arguments[index];
124  }
125 
126  protected internal override Expression Accept(ExpressionVisitor visitor)
127  {
128  return visitor.VisitIndex(this);
129  }
130 
131  internal Expression Rewrite(Expression instance, Expression[] arguments)
132  {
133  return Expression.MakeIndex(instance, _indexer, arguments ?? _arguments);
134  }
135  }
136 }
Provides the base class for a generic read-only collection.
Supports all classes in the .NET Framework class hierarchy and provides low-level services to derived...
Definition: Object.cs:18
Provides an internal interface for accessing the arguments of multiple tree nodes (DynamicExpression,...
Definition: __Canon.cs:3
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Definition: IEnumerable.cs:9
int ArgumentCount
Returns the number of arguments to the expression tree node. You should not use this type....
Expression GetArgument(int index)
Returns the argument at index, throwing if index is out of bounds. 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
PropertyInfo Indexer
Gets the T:System.Reflection.PropertyInfo for the property if the expression represents an indexed pr...
sealed override ExpressionType NodeType
Returns the node type of this T:System.Linq.Expressions.Expression.
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.
ReadOnlyCollection< Expression > Arguments
Gets the arguments that will be used to index the property or array.
Discovers the attributes of a property and provides access to property metadata.
Definition: PropertyInfo.cs:15
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
Represents indexing a property or array.
IndexExpression Update(Expression @object, IEnumerable< Expression > arguments)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...