Is there any method in EA repositories that I can use in my EA add-in to create custom code generation template in C#?

Viewed 58

I'm working on a C code generator add-in for EA. I spent quite a lot of time looking for any potential methods from EA repositories that would let me access the EA auto code generation templates. (I'm trying to find a way to create a custom template in C#) But so far I haven't found anything relevant. I'm wondering if there are methods that I can use to extend Enterprise Architect Add-in Framework, to create a custom code generation template? Or do I need to create a method from scratch?

1 Answers

Code generation templates can be included in an MDG.

And you supply the MDG from an add-in, and get your code generation template in EA that way.

In order tell give EA the MDG xml, you have to implement the method EA_OnInitializeTechnologies

This is an example taken from my addin EA JSON

    /// <summary>
    /// return the MDG content for the JSON MDG (so it doesn't have to be loaded separately
    /// </summary>
    /// <param name="Repository"></param>
    /// <returns>the MDG file contents</returns>
    public override object EA_OnInitializeTechnologies(Repository Repository)
    {
        return Properties.Resources.JSON_MDG;
    }

More details on how to generate the MDG file can be found in the manual

You'll need to check the Code Modules checkbox when generating an MDG technology

enter image description here

This will allow you to select the code generation templates, datatypes, etc.. enter image description here

If you don't need the add-in for anything else, you might be able to simply use the MDG instead of the add-in.

Related