Sparx Systems Forum

Enterprise Architect => Suggestions and Requests => Topic started by: Tehila1 on November 25, 2013, 12:20:03 am

Title: EA add-ins
Post by: Tehila1 on November 25, 2013, 12:20:03 am
Hello everybody!
I develop some add-in for EA using c#.
I created a singleton class used to access EA.Repository from the different methods, instead of sending the repository as a parameter each time.
Any idea how to relate EA.Repository to this class?

public sealed class EARepository
      {
            private static EARepository instance= new EARepository();
            private EA.Repository Repository;//member to hold repository
             public static EARepository GetRepository
            {
                  get
                  {
                        return instance;
                  }
            }
            private EARepository()
            {
            }
      }
Thanks in advance.
Title: Re: EA add-ins
Post by: Helmut Ortmann on November 26, 2013, 07:08:34 am
Hello,

I don't know why you want to use a singleton. In my opinion EA handles all this stuff.

Usually I use the EA_OnPostInitialized(EA.Repository Repository) to store the repository to an instance variable. After that I can us the instance variable. On EA_FileClose(EA.Repository Repository) you have to reset (set to null) the instance variable.

Helmut