【发布时间】:2009-09-11 10:03:50
【问题描述】:
我可以将 IronPython 2 类返回到我的 C#。 IronPython 2 调用该类成员的新方法是什么?
object ironPythonClass = scope.GetVariable("Hamish");
object[] args = new object[0];
object pythonObject = engine.Operations.Call(ironPythonClass, args);
var member = "Home";
// old way IronPython 1
// var methodResult = Ops.Invoke(this.pythonObject, SymbolTable.StringToId(member), args);
我以为我要做的就是
var methodResult = PythonOps.Invoke(codeContext, pythonObject, SymbolTable.StringToId(member), args);
但创建一个虚拟的 CodeContext 似乎并不正确。我觉得好像我应该能够从我的
code.Execute();
运行创建类的 Python 文件,以及该执行产生的范围。
【问题讨论】:
标签: c# ironpython