mscorlib(4.0.0.0) API with additions
ConditionalExpression.cs
1 using System.Diagnostics;
2 
4 {
6  [DebuggerTypeProxy(typeof(ConditionalExpressionProxy))]
7  [global::__DynamicallyInvokable]
9  {
10  private readonly Expression _test;
11 
12  private readonly Expression _true;
13 
16  [global::__DynamicallyInvokable]
17  public sealed override ExpressionType NodeType
18  {
19  [global::__DynamicallyInvokable]
20  get
21  {
22  return ExpressionType.Conditional;
23  }
24  }
25 
28  [global::__DynamicallyInvokable]
29  public override Type Type
30  {
31  [global::__DynamicallyInvokable]
32  get
33  {
34  return IfTrue.Type;
35  }
36  }
37 
40  [global::__DynamicallyInvokable]
41  public Expression Test
42  {
43  [global::__DynamicallyInvokable]
44  get
45  {
46  return _test;
47  }
48  }
49 
52  [global::__DynamicallyInvokable]
53  public Expression IfTrue
54  {
55  [global::__DynamicallyInvokable]
56  get
57  {
58  return _true;
59  }
60  }
61 
64  [global::__DynamicallyInvokable]
65  public Expression IfFalse
66  {
67  [global::__DynamicallyInvokable]
68  get
69  {
70  return GetFalse();
71  }
72  }
73 
74  internal ConditionalExpression(Expression test, Expression ifTrue)
75  {
76  _test = test;
77  _true = ifTrue;
78  }
79 
80  internal static ConditionalExpression Make(Expression test, Expression ifTrue, Expression ifFalse, Type type)
81  {
82  if (ifTrue.Type != type || ifFalse.Type != type)
83  {
84  return new FullConditionalExpressionWithType(test, ifTrue, ifFalse, type);
85  }
86  if (ifFalse is DefaultExpression && ifFalse.Type == typeof(void))
87  {
88  return new ConditionalExpression(test, ifTrue);
89  }
90  return new FullConditionalExpression(test, ifTrue, ifFalse);
91  }
92 
93  internal virtual Expression GetFalse()
94  {
95  return Expression.Empty();
96  }
97 
101  [global::__DynamicallyInvokable]
102  protected internal override Expression Accept(ExpressionVisitor visitor)
103  {
104  return visitor.VisitConditional(this);
105  }
106 
112  [global::__DynamicallyInvokable]
114  {
115  if (test == Test && ifTrue == IfTrue && ifFalse == IfFalse)
116  {
117  return this;
118  }
119  return Expression.Condition(test, ifTrue, ifFalse, Type);
120  }
121  }
122 }
Expression Test
Gets the test of the conditional operation.
Definition: __Canon.cs:3
Provides the base class from which the classes that represent expression tree nodes are derived....
Definition: Expression.cs:17
internal override Expression Accept(ExpressionVisitor visitor)
Dispatches to the specific visit method for this node type. For example, T:System....
sealed override ExpressionType NodeType
Returns the node type of this expression. Extension nodes should return F:System.Linq....
ConditionalExpression Update(Expression test, Expression ifTrue, Expression ifFalse)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
Expression IfFalse
Gets the expression to execute if the test evaluates to false.
virtual internal Expression VisitConditional(ConditionalExpression node)
Visits the children of the T:System.Linq.Expressions.ConditionalExpression.
ExpressionType
Describes the node types for the nodes of an expression tree.
Expression IfTrue
Gets the expression to execute if the test evaluates to true.
Represents an expression that has a conditional operator.
Represents a visitor or rewriter for expression trees.