public AddinManager(PermissionManager permissionManager, AssemblyManager assemblyManager, BusinessOneDAO b1DAO, I18NService i18nService, AssemblyDAO assemblyDAO, AddinLoader addinLoader) { this.permissionManager = permissionManager; this.assemblyDAO = assemblyDAO; this.b1DAO = b1DAO; this.i18nService = i18nService; this.assemblyManager = assemblyManager; this.addinLoader = addinLoader; }
internal void Run() { var setup = new AppDomainSetup(); setup.ApplicationName = "Dover.Inception"; setup.ApplicationBase = Environment.CurrentDirectory; var domain = AppDomain.CreateDomain("Dover.AddIn", null, setup); domain.SetData("shutdownEvent", shutdownEvent); // Thread synchronization domain.SetData("assemblyName", asm.Name); // Used to get current AssemblyName for logging and reflection domain.SetData("frameworkManager", frameworkAddinManager); Application app = (Application)domain.CreateInstanceAndUnwrap("Framework", "Dover.Framework.Application"); SAPServiceFactory.PrepareForInception(domain); addinB1SResourceManager = app.Resolve <B1SResourceManager>(); addinFormEventHandler = app.Resolve <FormEventHandler>(); addinLoader = app.Resolve <AddinLoader>(); eventDispatcher = app.Resolve <EventDispatcher>(); Sponsor <Application> appSponsor = new Sponsor <Application>(app); Sponsor <B1SResourceManager> b1sSponsor = new Sponsor <B1SResourceManager>(addinB1SResourceManager); Sponsor <FormEventHandler> formEventSponsor = new Sponsor <FormEventHandler>(addinFormEventHandler); Sponsor <AddinLoader> loaderSponsor = new Sponsor <AddinLoader>(addinLoader); Sponsor <EventDispatcher> eventSponsor = new Sponsor <EventDispatcher>(eventDispatcher); try { app.RunAddin(); AppDomain.Unload(domain); } catch (AppDomainUnloadedException e) { // ignore and continue shutdown. } finally { runningAddins.Remove(this); runningAddinsHash.Remove(asm.Name); } }