Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: McMannus on March 24, 2018, 04:51:22 am

Title: Indexed parameter compatibility issues in EA_PreNewElement
Post by: McMannus on March 24, 2018, 04:51:22 am
Hi all,

due to having had now incompatibility issues on three version changes of EA (11->12, 12->13, 13->13.5), I wanted to make the knowledge explicit, how to circumvent these issues.

The affected method was the EA_OnPreNewElement broadcast event with its signature
Code: [Select]
bool EA_OnPreNewElement(IDualRepository repository, EventProperties info)The EventProperties parameter is a class that contains a list of arbitrary data that can be accessed by
Code: [Select]
EventProperties.Get(object Index)This class is used as parameter in several of EA's broadcast events.

The problem with the usage of this class is that there are two ways of accessing the data in the event properties: either by passing a zero-based index to access a certain value in the list Props.Get(3) or by using a string identifier for the content which should be retrieved Props.Get("ObjectID").

If you use the index-based access (like I did since the beginning of my add-in writing. Don't even know, if the associative access was possible back then), you have to rely on the fact that the order of contents in the event properties is not changed.
Following is a small history of the event properties content and order in EA_OnPreNewElement:
EA 11:
0 Type 1 Stereotype 2 ParentID 3 DiagramID
EA 12:
0 Type 1 Stereotype 2 ParentID 3 DiagramID --> the parent ID delivered in EA12 is not anymore the direct element the element was dragged to, but the outmost parent element in the diagram
EA 13:
0 Type 1 FQStereotype 2 Stereotype 3 ParentID 4 DiagramID --> FQStereotype inserted in the middle of the list
EA 13.5:
0 Type 1 ParentID 2 DiagramID 3 Stereotype 4 FQStereotype --> Stereotype and FQStereotype moved to the end of the list

Without commenting this observation further, only two recommendations :):

Just my two cents on the topic
Jan