public void Dispose() { if (_owner != null) { var updateSource = (IDiagnosticUpdateSource)_owner._diagnosticService; updateSource.DiagnosticsUpdated -= OnDiagnosticsUpdated; } if (_workspaceStatusService != null) { _workspaceStatusService.StatusChanged -= OnWorkspaceStatusChanged; } if (_workspace != null) { _workspace.DocumentActiveContextChanged -= OnActiveContextChanged; } if (_registration != null) { _registration.WorkspaceChanged -= OnWorkspaceChanged; } if (_textView != null) { _textView.Closed -= OnTextViewClosed; } _owner = null; _workspace = null; _workspaceStatusService = null; _registration = null; _textView = null; _subjectBuffer = null; }
private void RegisterEventsToWorkspace(Workspace workspace) { _workspace = workspace; if (_workspace == null) { return; } _workspace.DocumentActiveContextChanged += OnActiveContextChanged; _workspaceStatusService = workspace.Services.GetService <IWorkspaceStatusService>(); if (_workspaceStatusService != null) { _workspaceStatusService.StatusChanged += OnWorkspaceStatusChanged; } }