4

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!

0

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry, it was a typing mistake in this example, but the problem persists
@user1275011: the code works fine in my tests, so probably you are doing something different from me. Can you post more code (possibly a small but complete example reproducing the issue)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.