コード例 #1
0
        /// <include file='doc\DesignerPackage.uex' path='docs/doc[@for="DesignerPackage.OnCreateService"]/*' />
        /// <devdoc>
        ///     Demand creates the requested service.
        /// </devdoc>
        private object OnCreateService(IServiceContainer container, Type serviceType)
        {
            if (serviceType == typeof(IVSMDPropertyBrowser))
            {
                return(new PropertyBrowserService());
            }
            if (serviceType == typeof(IToolboxService))
            {
                if (toolboxService == null)
                {
                    toolboxService = new ToolboxService();
                }
                return(toolboxService);
            }
            if (serviceType == typeof(IVSMDDesignerService))
            {
                return(new DesignerService());
            }
            if (serviceType == typeof(DocumentManager) || serviceType == typeof(IDesignerEventService))
            {
                if (documentManager == null)
                {
                    documentManager = new ShellDocumentManager(this);
                }
                return(documentManager);
            }
            if (serviceType == typeof(ITypeResolutionServiceProvider))
            {
                if (typeLoaderService == null)
                {
                    typeLoaderService = new ShellTypeLoaderService(this);
                }
                return(typeLoaderService);
            }
            if (serviceType == typeof(ILicenseManagerService))
            {
                if (licenseManagerService == null)
                {
                    licenseManagerService = new ShellLicenseManagerService(this);
                }
                return(licenseManagerService);
            }
            if (serviceType == typeof(IAssemblyEnumerationService))
            {
                return(new AssemblyEnumerationService(this));
            }

            if (serviceType == typeof(IHelpService))
            {
                return(new HelpService(this));
            }

            Debug.Fail("Container requested a service we didn't say we could provide");
            return(null);
        }
コード例 #2
0
        /// <include file='doc\DesignerPackage.uex' path='docs/doc[@for="DesignerPackage.Close"]/*' />
        /// <devdoc>
        ///     Overrides Close to clean up our editor factory.
        /// </devdoc>
        public override void Close()
        {
            SystemEvents.DisplaySettingsChanged -= new EventHandler(this.OnSystemSettingChanged);
            SystemEvents.InstalledFontsChanged  -= new EventHandler(this.OnSystemSettingChanged);
            SystemEvents.UserPreferenceChanged  -= new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged);

            if (editorFactory != null)
            {
                try {
                    editorFactory.Dispose();
                }
                catch (Exception e) {
                    Debug.Fail(e.ToString());
                }
                editorFactory = null;
            }

            if (documentManager != null)
            {
                documentManager.Dispose();
                documentManager = null;
            }

            if (typeLoaderService != null)
            {
                typeLoaderService.Dispose();
                typeLoaderService = null;
            }

            if (licenseManagerService != null)
            {
                licenseManagerService.Dispose();
                licenseManagerService = null;
            }

            if (toolboxService != null)
            {
                toolboxService.Dispose();
                toolboxService = null;
            }

            #if PERFEVENTS
            if (performanceEvent != IntPtr.Zero)
            {
                NativeMethods.CloseHandle(performanceEvent);
                performanceEvent = IntPtr.Zero;
            }
            #endif

            base.Close();
        }