public override bool TryBinaryOperation(BinaryOperationBinder binder, Object arg, out Object result) { IntPtr res; if (!(arg is PyObject)) arg = arg.ToPython(); switch (binder.Operation) { case ExpressionType.Add: res = Runtime.PyNumber_Add(this.obj, ((PyObject)arg).obj); break; case ExpressionType.AddAssign: res = Runtime.PyNumber_InPlaceAdd(this.obj, ((PyObject)arg).obj); break; case ExpressionType.Subtract: res = Runtime.PyNumber_Subtract(this.obj, ((PyObject)arg).obj); break; case ExpressionType.SubtractAssign: res = Runtime.PyNumber_InPlaceSubtract(this.obj, ((PyObject)arg).obj); break; case ExpressionType.Multiply: res = Runtime.PyNumber_Multiply(this.obj, ((PyObject)arg).obj); break; case ExpressionType.MultiplyAssign: res = Runtime.PyNumber_InPlaceMultiply(this.obj, ((PyObject)arg).obj); break; case ExpressionType.Divide: res = Runtime.PyNumber_Divide(this.obj, ((PyObject)arg).obj); break; case ExpressionType.DivideAssign: res = Runtime.PyNumber_InPlaceDivide(this.obj, ((PyObject)arg).obj); break; case ExpressionType.And: res = Runtime.PyNumber_And(this.obj, ((PyObject)arg).obj); break; case ExpressionType.AndAssign: res = Runtime.PyNumber_InPlaceAnd(this.obj, ((PyObject)arg).obj); break; case ExpressionType.ExclusiveOr: res = Runtime.PyNumber_Xor(this.obj, ((PyObject)arg).obj); break; case ExpressionType.ExclusiveOrAssign: res = Runtime.PyNumber_InPlaceXor(this.obj, ((PyObject)arg).obj); break; case ExpressionType.GreaterThan: result = Runtime.PyObject_Compare(this.obj, ((PyObject)arg).obj) > 0; return true; case ExpressionType.GreaterThanOrEqual: result = Runtime.PyObject_Compare(this.obj, ((PyObject)arg).obj) >= 0; return true; case ExpressionType.LeftShift: res = Runtime.PyNumber_Lshift(this.obj, ((PyObject)arg).obj); break; case ExpressionType.LeftShiftAssign: res = Runtime.PyNumber_InPlaceLshift(this.obj, ((PyObject)arg).obj); break; case ExpressionType.LessThan: result = Runtime.PyObject_Compare(this.obj, ((PyObject)arg).obj) < 0; return true; case ExpressionType.LessThanOrEqual: result = Runtime.PyObject_Compare(this.obj, ((PyObject)arg).obj) <= 0; return true; case ExpressionType.Modulo: res = Runtime.PyNumber_Remainder(this.obj, ((PyObject)arg).obj); break; case ExpressionType.ModuloAssign: res = Runtime.PyNumber_InPlaceRemainder(this.obj, ((PyObject)arg).obj); break; case ExpressionType.NotEqual: result = Runtime.PyObject_Compare(this.obj, ((PyObject)arg).obj) != 0; return true; case ExpressionType.Or: res = Runtime.PyNumber_Or(this.obj, ((PyObject)arg).obj); break; case ExpressionType.OrAssign: res = Runtime.PyNumber_InPlaceOr(this.obj, ((PyObject)arg).obj); break; case ExpressionType.Power: res = Runtime.PyNumber_Power(this.obj, ((PyObject)arg).obj); break; case ExpressionType.RightShift: res = Runtime.PyNumber_Rshift(this.obj, ((PyObject)arg).obj); break; case ExpressionType.RightShiftAssign: res = Runtime.PyNumber_InPlaceRshift(this.obj, ((PyObject)arg).obj); break; default: result = null; return false; } result = new PyObject(res); return true; }