Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Kevin Winchester on February 06, 2008, 12:32:34 pm
-
I am developing some automation interface (C#) code to create and update connectors, and it seems to take a very long time to execute.
The standard pattern of the code is:
- For each connector in an element:
- if (this connector == the connector to update)
- keep a reference to the connector and break
- end loop
- if reference to connector is null
- AddNew connector and keep the reference
- endif
- write to the connector properties (e.g. stereotype)
- update the connector
- write to the connector ends
- update the connector ends
- add/update some tagged values to the connector
- update & refresh the tagged values
Is this a good way to be performing these addition/updates? Is there some way to enhance the speed?
-
Well, first, how are you comparing connectors? If you have an solid naming convention or anything you might be able to avoid the loop.
You can speed up connector update code alot by fine tuning when you update. You'll always need to do one at the end, but you can usually edit all the non-object properties in a group before calling it. If you change supplier/client ID and then reference those ends, you do have to update. However, I'm relatively sure that updating the connector handles the ends for you, so that you can do without.
-
Thanks for the reply.
I am comparing connectors by looking at a number of features of the connector (Type, ConnectorEnd roles, etc.).
I have since improved the code somewhat by checking the existing value of the connector properties and not calling Update() unless I am changing something. This helps in the case of a connector that doesn't need any changes.
In general, I guess there isn't any magic speed trick that will make a large difference, other than accessing the project database directly.