2

Well, need to translate c# code into IronPython. The current problem is to find the best way to traslate initialization like this for example:

case SomeObject.FieldCase: new SomeObject { Width = 600, Height = 400 }.Export(model_, stream); break;

Do you have any ideas to make it similar? I'm interesting only in object initialization code, case statement was translated. For translation we use Roslyn, so we can get all syntax nodes. In other cases I make smth like that:

model = new Model; model.SomeField = field; model.SomeField2 = field2;

But this way is not so easy to develop.

3
  • Am I right in assuming that you do not care about the case and the export call but only object construction? Can SomeObject be modified or wrapped in any way? Have you seen stackoverflow.com/a/2466207/468244 and stackoverflow.com/a/17283996/468244 ? or is that to intrusive? Commented Feb 8, 2017 at 10:59
  • You're right, I care only about object construction. SomeObject cannot be modified or wrapped. Namedtuples can help, I think. Commented Feb 8, 2017 at 13:27
  • Well, tuple is not a good idea, because we need to call methods from class. Commented Feb 8, 2017 at 15:48

1 Answer 1

2

Found. IronPython can use c# classes, using import and change initializer invocation value= new SomeObject { Name = name } to value = SomeObject(Name = name)

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

Comments

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.