mscorlib(4.0.0.0) API with additions
UnaryOperationBinder.cs
1 using System.Dynamic.Utils;
3 
4 namespace System.Dynamic
5 {
7  [global::__DynamicallyInvokable]
9  {
10  private ExpressionType _operation;
11 
14  [global::__DynamicallyInvokable]
15  public sealed override Type ReturnType
16  {
17  [global::__DynamicallyInvokable]
18  get
19  {
20  ExpressionType operation = _operation;
21  if (operation == ExpressionType.IsTrue || operation == ExpressionType.IsFalse)
22  {
23  return typeof(bool);
24  }
25  return typeof(object);
26  }
27  }
28 
31  [global::__DynamicallyInvokable]
33  {
34  [global::__DynamicallyInvokable]
35  get
36  {
37  return _operation;
38  }
39  }
40 
41  internal sealed override bool IsStandardBinder => true;
42 
45  [global::__DynamicallyInvokable]
46  protected UnaryOperationBinder(ExpressionType operation)
47  {
48  ContractUtils.Requires(OperationIsValid(operation), "operation");
49  _operation = operation;
50  }
51 
55  [global::__DynamicallyInvokable]
57  {
58  return FallbackUnaryOperation(target, null);
59  }
60 
65  [global::__DynamicallyInvokable]
66  public abstract DynamicMetaObject FallbackUnaryOperation(DynamicMetaObject target, DynamicMetaObject errorSuggestion);
67 
72  [global::__DynamicallyInvokable]
73  public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
74  {
75  ContractUtils.RequiresNotNull(target, "target");
76  ContractUtils.Requires(args == null || args.Length == 0, "args");
77  return target.BindUnaryOperation(this);
78  }
79 
80  internal static bool OperationIsValid(ExpressionType operation)
81  {
82  switch (operation)
83  {
84  case ExpressionType.Negate:
85  case ExpressionType.UnaryPlus:
86  case ExpressionType.Not:
87  case ExpressionType.Decrement:
88  case ExpressionType.Extension:
89  case ExpressionType.Increment:
90  case ExpressionType.OnesComplement:
91  case ExpressionType.IsTrue:
92  case ExpressionType.IsFalse:
93  return true;
94  default:
95  return false;
96  }
97  }
98  }
99 }
UnaryOperationBinder(ExpressionType operation)
Initializes a new instance of the T:System.Dynamic.BinaryOperationBinder class.
Represents the dynamic binding and a binding logic of an object participating in the dynamic binding.
Definition: __Canon.cs:3
DynamicMetaObject FallbackUnaryOperation(DynamicMetaObject target)
Performs the binding of the unary dynamic operation if the target dynamic object cannot bind.
sealed override Type ReturnType
The result type of the operation.
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
The dynamic call site binder that participates in the T:System.Dynamic.DynamicMetaObject binding prot...
ExpressionType Operation
The unary operation kind.
ExpressionType
Describes the node types for the nodes of an expression tree.
sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
Performs the binding of the dynamic unary operation.
Represents the unary dynamic operation at the call site, providing the binding semantic and the detai...
virtual DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
Performs the binding of the dynamic unary operation.