本文整理汇总了C#中System.Object.ToPython方法的典型用法代码示例。如果您正苦于以下问题:C# Object.ToPython方法的具体用法?C# Object.ToPython怎么用?C# Object.ToPython使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Object
的用法示例。
在下文中一共展示了Object.ToPython方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryBinaryOperation
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;
}