/// <summary> /// Provides implementation for binary operations. Classes derived from the <see cref="T:System.Dynamic.DynamicObject" /> class can override this method to specify dynamic behavior for operations such as addition and multiplication. /// </summary> /// <param name="binder">Provides information about the binary operation. The binder.Operation property returns an <see cref="T:System.Linq.Expressions.ExpressionType" /> object. For example, for the sum = first + second statement, where first and second are derived from the DynamicObject class, binder.Operation returns ExpressionType.Add.</param> /// <param name="arg">The right operand for the binary operation. For example, for the sum = first + second statement, where first and second are derived from the DynamicObject class, <paramref name="arg" /> is equal to second.</param> /// <param name="result">The result of the binary operation.</param> /// <returns> /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.) /// </returns> public override bool TryBinaryOperation(System.Dynamic.BinaryOperationBinder binder, object arg, out object result) { //If we are binding from another dynamic object then our method info will be bound to an object if (typeof(BoundMethodInfo).IsAssignableFrom(arg.GetType())) { BoundMethodInfo mi = (BoundMethodInfo)arg; //Create a delegate from the method instance on the bound object arg = Delegate.CreateDelegate(this.BoundEvent.EventHandlerType, mi.BoundObject, mi.MethodInfo); } //If we have a delegate then handle assigning the event handler if (typeof(Delegate).IsAssignableFrom(arg.GetType())) { switch (binder.Operation) { case System.Linq.Expressions.ExpressionType.AddAssign: this.BoundEvent.GetAddMethod(true).Invoke(base.Target, new[] { arg }); break; case System.Linq.Expressions.ExpressionType.SubtractAssign: this.BoundEvent.GetRemoveMethod(true).Invoke(base.Target, new[] { arg }); break; default: throw new NotImplementedException(); } result = null; return(true); } return(base.TryBinaryOperation(binder, arg, out result)); }
public virtual bool TryBinaryOperation(System.Dynamic.BinaryOperationBinder binder, object arg, out object result) { throw null; }
public virtual System.Dynamic.DynamicMetaObject BindBinaryOperation(System.Dynamic.BinaryOperationBinder binder, System.Dynamic.DynamicMetaObject arg) { throw null; }
public virtual bool TryBinaryOperation(System.Dynamic.BinaryOperationBinder binder, object arg, out object result) { result = default(object); return(default(bool)); }
public virtual System.Dynamic.DynamicMetaObject BindBinaryOperation(System.Dynamic.BinaryOperationBinder binder, System.Dynamic.DynamicMetaObject arg) { return(default(System.Dynamic.DynamicMetaObject)); }