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.

ArgorAvest
  • 151
  • 1
  • 1
  • 11
  • 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 http://stackoverflow.com/a/2466207/468244 and http://stackoverflow.com/a/17283996/468244 ? or is that to intrusive? – Simon Opelt Feb 08 '17 at 10:59
  • You're right, I care only about object construction. SomeObject cannot be modified or wrapped. Namedtuples can help, I think. – ArgorAvest Feb 08 '17 at 13:27
  • Well, tuple is not a good idea, because we need to call methods from class. – ArgorAvest Feb 08 '17 at 15:48

1 Answers1

2

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

ArgorAvest
  • 151
  • 1
  • 1
  • 11