mscorlib(4.0.0.0) API with additions
BinaryOperationBinder.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  return typeof(object);
21  }
22  }
23 
26  [global::__DynamicallyInvokable]
28  {
29  [global::__DynamicallyInvokable]
30  get
31  {
32  return _operation;
33  }
34  }
35 
36  internal sealed override bool IsStandardBinder => true;
37 
40  [global::__DynamicallyInvokable]
42  {
43  ContractUtils.Requires(OperationIsValid(operation), "operation");
44  _operation = operation;
45  }
46 
51  [global::__DynamicallyInvokable]
53  {
54  return FallbackBinaryOperation(target, arg, null);
55  }
56 
62  [global::__DynamicallyInvokable]
64 
69  [global::__DynamicallyInvokable]
70  public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
71  {
72  ContractUtils.RequiresNotNull(target, "target");
73  ContractUtils.RequiresNotNull(args, "args");
74  ContractUtils.Requires(args.Length == 1, "args");
75  DynamicMetaObject dynamicMetaObject = args[0];
76  ContractUtils.RequiresNotNull(dynamicMetaObject, "args");
77  return target.BindBinaryOperation(this, dynamicMetaObject);
78  }
79 
80  internal static bool OperationIsValid(ExpressionType operation)
81  {
82  switch (operation)
83  {
84  case ExpressionType.Add:
85  case ExpressionType.And:
86  case ExpressionType.Divide:
87  case ExpressionType.Equal:
88  case ExpressionType.ExclusiveOr:
89  case ExpressionType.GreaterThan:
90  case ExpressionType.GreaterThanOrEqual:
91  case ExpressionType.LeftShift:
92  case ExpressionType.LessThan:
93  case ExpressionType.LessThanOrEqual:
94  case ExpressionType.Modulo:
95  case ExpressionType.Multiply:
96  case ExpressionType.NotEqual:
97  case ExpressionType.Or:
98  case ExpressionType.Power:
99  case ExpressionType.RightShift:
100  case ExpressionType.Subtract:
101  case ExpressionType.Extension:
102  case ExpressionType.AddAssign:
103  case ExpressionType.AndAssign:
104  case ExpressionType.DivideAssign:
105  case ExpressionType.ExclusiveOrAssign:
106  case ExpressionType.LeftShiftAssign:
107  case ExpressionType.ModuloAssign:
108  case ExpressionType.MultiplyAssign:
109  case ExpressionType.OrAssign:
110  case ExpressionType.PowerAssign:
111  case ExpressionType.RightShiftAssign:
112  case ExpressionType.SubtractAssign:
113  return true;
114  default:
115  return false;
116  }
117  }
118  }
119 }
sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
Performs the binding of the dynamic binary operation.
Represents the dynamic binding and a binding logic of an object participating in the dynamic binding.
Definition: __Canon.cs:3
BinaryOperationBinder(ExpressionType operation)
Initializes a new instance of the T:System.Dynamic.BinaryOperationBinder class.
DynamicMetaObject FallbackBinaryOperation(DynamicMetaObject target, DynamicMetaObject arg)
Performs the binding of the binary dynamic operation if the target dynamic object cannot bind.
virtual DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg)
Performs the binding of the dynamic binary operation.
ExpressionType Operation
The binary operation kind.
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
Describes the node types for the nodes of an expression tree.
sealed override Type ReturnType
The result type of the operation.
Represents the binary dynamic operation at the call site, providing the binding semantic and the deta...