Search code examples
c#enterprise-architect

How to provide stereotype for Package in Enterprise Architect?


I am trying to create EA package from C# Addin. I am able to create the package but, when I am trying to set the stereotype for package from C# code then its not getting set. I am using the below code to set the stereotype for package.

packageCreate = (EA.Package)getModel.Packages.AddNew(pacName, "");
                    packageCreate.StereotypeEx = "TCL";
                    packageCreate.Update();

How to provide Stereotype to EA Package using C# ?


Solution

  • You need to add the stereotype to the package's element

    packageCreate.Update();
    packageCreate.Element.StereotypeEx = "TCL";
    packageCreate.Update();
    

    The difference between Stereotype and StereotypeEx is subtile. Stereotype delivers the first stereo of a list while Ex returns a comma separated list. When assigning stereos, the Ex variant splits by comma first and assigns each separately. Stereotypein contrast stores the value directly and this results in really strange effects.

    This and other Ex properties were introduced in later EA versions. So rather than fixing the basic one, they added an extra property to increase confusion. EAUI.