Exemple #1
0
 //init services
 private void InitializeApplication()
 {
     ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService);
     this._serviceContainer = new ServiceContainer();
     this._serviceContainer.AddService(typeof(IApplicationIdentity), this);
     this._exceptionHandler = new GlobalExceptionHandler(this._serviceContainer);
     this._exceptionHandler.Initialize();
     this._prefService = new PreferencesService(this._serviceContainer);
     this._prefService.Load(this._commandLine.Options.Contains("reset"));
     this._serviceContainer.AddService(typeof(IPreferencesService), this._prefService);
     this._packageManager = new PackageManager(this._serviceContainer);
     this._serviceContainer.AddService(typeof(IPackageManager), this._packageManager);
     this._serviceContainer.AddService(typeof(IPrintService), callback);
     this._serviceContainer.AddService(typeof(IWebBrowsingService), callback);
     this._serviceContainer.AddService(typeof(IComponentGalleryService), callback);
     this._serviceContainer.AddService(typeof(IDataObjectMappingService), callback);
     if ((this.ApplicationType & ApplicationType.Workspace) != ApplicationType.Generic)
     {
         this._projectManager = new ProjectManager(this._serviceContainer);
         this._serviceContainer.AddService(typeof(IProjectManager), this._projectManager);
         this._languageManager = new LanguageManager(this._serviceContainer);
         this._serviceContainer.AddService(typeof(ILanguageManager), this._languageManager);
         this._docTypeManager = new DocumentTypeManager(this._serviceContainer);
         this._serviceContainer.AddService(typeof(IDocumentTypeManager), this._docTypeManager);
         this._docManager = new DocumentManager(this._serviceContainer, (this.ApplicationType & ApplicationType.Debugger) != ApplicationType.Generic);
         this._serviceContainer.AddService(typeof(IDocumentManager), this._docManager);
         this._serviceContainer.AddService(typeof(IDesignerEventService), this._docManager);
         this._toolboxService = new ToolboxService(this._serviceContainer);
         this._serviceContainer.AddService(typeof(IToolboxService), this._toolboxService);
     }
 }
Exemple #2
0
 private void CloseApplication()
 {
     if ((this.ApplicationType & Microsoft.Matrix.Core.Application.ApplicationType.Workspace) != Microsoft.Matrix.Core.Application.ApplicationType.Generic)
     {
         this._serviceContainer.RemoveService(typeof(IToolboxService));
         if (this._toolboxService != null)
         {
             ((IDisposable) this._toolboxService).Dispose();
             this._toolboxService = null;
         }
         this._serviceContainer.RemoveService(typeof(IDocumentManager));
         this._serviceContainer.RemoveService(typeof(IDesignerEventService));
         if (this._docManager != null)
         {
             ((IDisposable) this._docManager).Dispose();
             this._docManager = null;
         }
         this._serviceContainer.RemoveService(typeof(IDocumentTypeManager));
         if (this._docTypeManager != null)
         {
             ((IDisposable) this._docTypeManager).Dispose();
             this._docTypeManager = null;
         }
         this._serviceContainer.RemoveService(typeof(ILanguageManager));
         if (this._languageManager != null)
         {
             ((IDisposable) this._languageManager).Dispose();
             this._languageManager = null;
         }
         this._serviceContainer.RemoveService(typeof(IProjectManager));
         if (this._projectManager != null)
         {
             ((IDisposable) this._projectManager).Dispose();
             this._projectManager = null;
         }
     }
     this._serviceContainer.RemoveService(typeof(IDataObjectMappingService));
     if (this._dataObjectMappingService != null)
     {
         this._dataObjectMappingService = null;
     }
     this._serviceContainer.RemoveService(typeof(IComponentGalleryService));
     if (this._componentGalleryService != null)
     {
         ((IDisposable) this._componentGalleryService).Dispose();
         this._componentGalleryService = null;
     }
     this._serviceContainer.RemoveService(typeof(IWebBrowsingService));
     if (this._webBrowsingService != null)
     {
         ((IDisposable) this._webBrowsingService).Dispose();
         this._webBrowsingService = null;
     }
     this._serviceContainer.RemoveService(typeof(IPrintService));
     if (this._printService != null)
     {
         ((IDisposable) this._printService).Dispose();
         this._printService = null;
     }
     this._serviceContainer.RemoveService(typeof(IPackageManager));
     if (this._packageManager != null)
     {
         ((IDisposable) this._packageManager).Dispose();
         this._packageManager = null;
     }
     this._serviceContainer.RemoveService(typeof(IPreferencesService));
     if (this._prefService != null)
     {
         this._prefService.Save();
         ((IDisposable) this._prefService).Dispose();
         this._prefService = null;
     }
     ((IDisposable) this._exceptionHandler).Dispose();
     this._exceptionHandler = null;
     this._serviceContainer.RemoveService(typeof(IApplicationIdentity));
     this._serviceContainer = null;
 }