Dispose() public method

public Dispose ( ) : void
return void
示例#1
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            if (_parser != null && _parser.State != null)
            {
                _parser.State.StateChanged        -= Parser_StateChanged;
                _parser.State.StatusMessageUpdate -= State_StatusMessageUpdate;
                _parser.State.Dispose();
                _parser.Dispose();
                // I won't set this to null because other components may try to release things
            }

            if (_hooks != null)
            {
                _hooks.MessageReceived -= _hooks_MessageReceived;
                _hooks.Dispose();
                _hooks = null;
            }

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

            if (_configService != null)
            {
                _configService.SettingsChanged -= _configService_SettingsChanged;
                _configService = null;
            }

            if (_stateBar != null)
            {
                _stateBar.Refresh -= _stateBar_Refresh;
                _stateBar.Dispose();
                _stateBar = null;
            }

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

            UiDispatcher.Shutdown();

            _disposed = true;
        }
示例#2
0
        public void Dispose()
        {
            _configService.LanguageChanged -= ConfigServiceLanguageChanged;
            _parser.State.StateChanged     -= Parser_StateChanged;
            _autoSave.Dispose();

            _projectsEventsConnectionPoint.Unadvise(_projectsEventsCookie);
            foreach (var item in _componentsEventsConnectionPoints)
            {
                item.Value.Item1.Unadvise(item.Value.Item2);
            }
            foreach (var item in _referencesEventsConnectionPoints)
            {
                item.Value.Item1.Unadvise(item.Value.Item2);
            }
            _hooks.Dispose();
        }
示例#3
0
文件: App.cs 项目: shairad/Rubberduck
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            if (_configService != null)
            {
                _configService.SettingsChanged -= _configService_SettingsChanged;
            }

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

            UiDispatcher.Shutdown();

            _disposed = true;
        }
示例#4
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            if (_sourceControlPanelVM != null)
            {
                _sourceControlPanelVM.OpenRepoStarted   -= DisableSinkEventHandlers;
                _sourceControlPanelVM.OpenRepoCompleted -= EnableSinkEventHandlersAndUpdateCache;
            }

            if (_branchesVM != null)
            {
                _branchesVM.LoadingComponentsStarted   -= DisableSinkEventHandlers;
                _branchesVM.LoadingComponentsCompleted -= EnableSinkEventHandlersAndUpdateCache;
            }

            _handleSinkEvents = false;

            if (_parser != null && _parser.State != null)
            {
                _parser.State.StateChanged        -= Parser_StateChanged;
                _parser.State.StatusMessageUpdate -= State_StatusMessageUpdate;
                _parser.Dispose();
                // I won't set this to null because other components may try to release things
            }

            if (_hooks != null)
            {
                _hooks.MessageReceived -= _hooks_MessageReceived;
                _hooks.Dispose();
                _hooks = null;
            }

            if (_configService != null)
            {
                _configService.SettingsChanged -= _configService_SettingsChanged;
                _configService.LanguageChanged -= ConfigServiceLanguageChanged;
                _configService = null;
            }

            if (_stateBar != null)
            {
                _stateBar.Refresh -= _stateBar_Refresh;
                _stateBar.Dispose();
                _stateBar = null;
            }

            if (_sink != null)
            {
                _sink.ProjectAdded     -= sink_ProjectAdded;
                _sink.ProjectRemoved   -= sink_ProjectRemoved;
                _sink.ProjectActivated -= sink_ProjectActivated;
                _sink.ProjectRenamed   -= sink_ProjectRenamed;
                _sink = null;
            }

            foreach (var item in _componentsEventsSinks)
            {
                item.Value.ComponentActivated -= sink_ComponentActivated;
                item.Value.ComponentAdded     -= sink_ComponentAdded;
                item.Value.ComponentReloaded  -= sink_ComponentReloaded;
                item.Value.ComponentRemoved   -= sink_ComponentRemoved;
                item.Value.ComponentRenamed   -= sink_ComponentRenamed;
                item.Value.ComponentSelected  -= sink_ComponentSelected;
            }

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

            _projectsEventsConnectionPoint.Unadvise(_projectsEventsCookie);
            foreach (var item in _componentsEventsConnectionPoints)
            {
                item.Value.Item1.Unadvise(item.Value.Item2);
            }
            foreach (var item in _referencesEventsConnectionPoints)
            {
                item.Value.Item1.Unadvise(item.Value.Item2);
            }

            UiDispatcher.Shutdown();

            _disposed = true;
        }