Reputation: 1772
i am implementing an interface defined in C# in ironPython, but cannot make property implementation work:
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:
Expected property for Elements, but found Dictionary[str, element]
What im doing wrong?
Thanks!
Upvotes: 4
Views: 929
Reputation: 57220
With def Implementor()
you're defining a method, not a class.
The correct code is 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).
Upvotes: 2