Inheritance: IDisposable
コード例 #1
0
        public App(VBE vbe, IMessageBox messageBox,
                   UI.Settings.Settings settings,
                   IRubberduckParser parser,
                   IGeneralConfigService configService,
                   IAppMenu appMenus,
                   RubberduckCommandBar stateBar,
                   IRubberduckHooks hooks)
        {
            _vbe           = vbe;
            _messageBox    = messageBox;
            _settings      = settings;
            _parser        = parser;
            _configService = configService;
            _autoSave      = new AutoSave.AutoSave(_vbe, _configService);
            _appMenus      = appMenus;
            _stateBar      = stateBar;
            _hooks         = hooks;

            _hooks.MessageReceived            += _hooks_MessageReceived;
            _configService.SettingsChanged    += _configService_SettingsChanged;
            _parser.State.StateChanged        += Parser_StateChanged;
            _parser.State.StatusMessageUpdate += State_StatusMessageUpdate;
            _stateBar.Refresh += _stateBar_Refresh;
            UiDispatcher.Initialize();
        }
コード例 #2
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;
        }
コード例 #3
0
ファイル: App.cs プロジェクト: grleachman/Rubberduck
        public App(VBE vbe, IMessageBox messageBox,
                   IRubberduckParser parser,
                   IGeneralConfigService configService,
                   IAppMenu appMenus,
                   RubberduckCommandBar stateBar,
                   IRubberduckHooks hooks,
                   SourceControlDockablePresenter sourceControlPresenter)
        {
            _vbe           = vbe;
            _messageBox    = messageBox;
            _parser        = parser;
            _configService = configService;
            _autoSave      = new AutoSave.AutoSave(_vbe, _configService);
            _appMenus      = appMenus;
            _stateBar      = stateBar;
            _hooks         = hooks;
            _logger        = LogManager.GetCurrentClassLogger();

            var sourceControlPanel = (SourceControlPanel)sourceControlPresenter.Window();

            _sourceControlPanelVM = (SourceControlViewViewModel)sourceControlPanel.ViewModel;
            _branchesVM           = (BranchesViewViewModel)_sourceControlPanelVM.TabItems.Single(t => t.ViewModel.Tab == SourceControlTab.Branches).ViewModel;

            _sourceControlPanelVM.OpenRepoStarted   += DisableSinkEventHandlers;
            _sourceControlPanelVM.OpenRepoCompleted += EnableSinkEventHandlersAndUpdateCache;

            _branchesVM.LoadingComponentsStarted   += DisableSinkEventHandlers;
            _branchesVM.LoadingComponentsCompleted += EnableSinkEventHandlersAndUpdateCache;

            _hooks.MessageReceived            += _hooks_MessageReceived;
            _configService.SettingsChanged    += _configService_SettingsChanged;
            _configService.LanguageChanged    += ConfigServiceLanguageChanged;
            _parser.State.StateChanged        += Parser_StateChanged;
            _parser.State.StatusMessageUpdate += State_StatusMessageUpdate;
            _stateBar.Refresh += _stateBar_Refresh;

            _sink = new VBProjectsEventsSink();
            var connectionPointContainer = (IConnectionPointContainer)_vbe.VBProjects;
            var interfaceId = typeof(_dispVBProjectsEvents).GUID;

            connectionPointContainer.FindConnectionPoint(ref interfaceId, out _projectsEventsConnectionPoint);

            _sink.ProjectAdded     += sink_ProjectAdded;
            _sink.ProjectRemoved   += sink_ProjectRemoved;
            _sink.ProjectActivated += sink_ProjectActivated;
            _sink.ProjectRenamed   += sink_ProjectRenamed;

            _projectsEventsConnectionPoint.Advise(_sink, out _projectsEventsCookie);
            UiDispatcher.Initialize();
        }
コード例 #4
0
ファイル: App.cs プロジェクト: shairad/Rubberduck
        public App(IVBE vbe,
                   IMessageBox messageBox,
                   IGeneralConfigService configService,
                   IAppMenu appMenus,
                   IRubberduckHooks hooks,
                   IVersionCheck version,
                   CommandBase checkVersionCommand)
        {
            _messageBox          = messageBox;
            _configService       = configService;
            _autoSave            = new AutoSave.AutoSave(vbe, _configService);
            _appMenus            = appMenus;
            _hooks               = hooks;
            _version             = version;
            _checkVersionCommand = checkVersionCommand;

            _configService.SettingsChanged += _configService_SettingsChanged;

            UiDispatcher.Initialize();
        }
コード例 #5
0
ファイル: App.cs プロジェクト: VillageSoftware/Rubberduck
        public App(VBE vbe, IMessageBox messageBox,
                   IRubberduckParser parser,
                   IGeneralConfigService configService,
                   IAppMenu appMenus,
                   RubberduckCommandBar stateBar,
                   IIndenter indenter,
                   IRubberduckHooks hooks)
        {
            _vbe           = vbe;
            _messageBox    = messageBox;
            _parser        = parser;
            _configService = configService;
            _autoSave      = new AutoSave.AutoSave(_vbe, _configService);
            _appMenus      = appMenus;
            _stateBar      = stateBar;
            _indenter      = indenter;
            _hooks         = hooks;
            _logger        = LogManager.GetCurrentClassLogger();

            _hooks.MessageReceived            += _hooks_MessageReceived;
            _configService.SettingsChanged    += _configService_SettingsChanged;
            _configService.LanguageChanged    += ConfigServiceLanguageChanged;
            _parser.State.StateChanged        += Parser_StateChanged;
            _parser.State.StatusMessageUpdate += State_StatusMessageUpdate;
            _stateBar.Refresh += _stateBar_Refresh;

            var sink = new VBProjectsEventsSink();
            var connectionPointContainer = (IConnectionPointContainer)_vbe.VBProjects;
            var interfaceId = typeof(_dispVBProjectsEvents).GUID;

            connectionPointContainer.FindConnectionPoint(ref interfaceId, out _projectsEventsConnectionPoint);

            sink.ProjectAdded     += sink_ProjectAdded;
            sink.ProjectRemoved   += sink_ProjectRemoved;
            sink.ProjectActivated += sink_ProjectActivated;
            sink.ProjectRenamed   += sink_ProjectRenamed;

            _projectsEventsConnectionPoint.Advise(sink, out _projectsEventsCookie);

            UiDispatcher.Initialize();
        }
コード例 #6
0
ファイル: App.cs プロジェクト: grleachman/Rubberduck
        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;
        }