How to specify GUID of Delphi interface in Enterprise Architect?

I am using Enterprise Architect's code generation feature to export my models to Delphi code. Is there a way to specify front-end GUIDs in EA so that the interfaces are fully defined in the output code?

Example:

ILogger = interface
  procedure Log(AMessage: ILoggerMessage);
end;

      

it should be

ILogger = interface
['{16B77CF4-4219-412D-B1F3-20E29E2E9D9E}']
  procedure Log(AMessage: ILoggerMessage);
end;

      

+2


source to share


3 answers


You should add to the ILogger TaggedValue attribute a value containing the GUID in a form Delphi likes:

Attribute=['{16B77CF4-4219-412D-B1F3-20E29E2E9D9E}']

      

then you have to change your code templates class class and add



%classTag:"Attribute"%

      

as the second line (should come after the% if elemType == "Interface"%) EA should now correctly generate the code with the GUID. EA is importing it well, but not generating it properly.

This is a quick fix for interfaces, but I haven't programmed in Delphi for a long time, so I'm not sure if classes can have such attributes too, so the solution is limited to interfaces, for now :).

+1


source


Not. Delphi doesn't know if you need a GUID or not, since not all interfaces need to have one. (Interfaces that are not designed for COM and, for example, do not implement IDispatch.) The IDE cannot read your mind (yet - maybe there is hope for the future) and cannot know what type of interface you are using when scheduling creation.



+2


source


It looks like EA doesn't support interfaces like it does in COM programming. But you can try using the template editing feature to change the way the code is generated ...

0


source







All Articles