[英]IronPython implementing interface Properties
i am implementing an interface defined in C# in ironPython, but cannot make property implementation work: 我正在实现在IronPython中用C#定义的接口,但不能使属性实现工作:
C# C#
interface IInterface
{
Dictionary<string, element> Elements { get; }
}
Python: 蟒蛇:
class Implementor(IInterface):
def __init__(self):
self.elements = Dictionary[str, element]()
def get_Elements(self):
return self.elements
When calling to get_Elements, i get the following exception: 调用get_Elements时,我得到以下异常:
Expected property for Elements, but found Dictionary[str, element] Elements的预期属性,但找到了Dictionary [str,element]
What im doing wrong? 我做错了什么?
Thanks! 谢谢!
With def Implementor()
you're defining a method, not a class. 使用def Implementor()
您将定义一个方法,而不是一个类。
The correct code is class Implementor()
: 正确的代码是class Implementor()
:
class Implementor(IInterface):
def __init__(self):
self.elements = Dictionary[str, element]()
def get_Elements(self):
return self.elements
this code works fine in my tests (I fetched a Implementor instance variable from the python scope into C# and the property works fine). 这段代码在我的测试中工作正常(我从Python范围中将一个Implementor实例变量提取到C#中,属性工作正常)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.