Author Topic: EA add-ins  (Read 3046 times)

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
EA add-ins
« 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.

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: EA add-ins
« Reply #1 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



Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)