Author Topic: Dynamically set EA Property by C# (reflection)  (Read 1159 times)

Helmut Ortmann

  • EA User
  • **
  • Posts: 909
  • Karma: +38/-1
    • View Profile
Dynamically set EA Property by C# (reflection)
« on: May 15, 2017, 02:37:16 am »
Hi,

I want to set an EA Property like 'ShowConstraints' (EA.DiagramObject) in C# dynamically / by reflection.

For datatypes 'long' or 'string' it works well by e.g.:
diaObj.GetType().InvokeMember("ElementDisplayMode", System.Reflection.BindingFlags.SetProperty, null, diaObj, new object[] { 2 });

On the first view, it looks as if 'true 'isn't correctly translated to the COM 'true'. I tried 1, 255, 65535, -1, ... - no success.

For datatype 'boolean', I can set it only to 'false' but never to 'true'. I tried a lot - no success. According to the documentation, it should work for COM interop. Yes, setting to 'false', 'reading' works well.

One of my tries:
diaObj.GetType().InvokeMember("ShowNotes", System.Reflection.BindingFlags.PutRefDispProperty, null, diaObj, new object[] { (true });

Any idea, experiences?

Thanks for your help.

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8033
  • Karma: +183/-22
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Dynamically set EA Property by C# (reflection)
« Reply #1 on: May 15, 2017, 04:50:41 pm »
Hi Helmut,

Nope, sorry, can't help. I never went in that specific rabbit hole.

Geert

Helmut Ortmann

  • EA User
  • **
  • Posts: 909
  • Karma: +38/-1
    • View Profile
Re: Dynamically set EA Property by C# (reflection)
« Reply #2 on: May 16, 2017, 02:42:48 pm »
Hi Geert,

thanks for your reply.

Maybe sometimes I stumble over the solution.

Kind regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)