/// <summary> /// Closes the document /// </summary> public virtual void Close() { if (IsClosed) { return; } IsClosed = true; _textDocumentFactoryService.TextDocumentDisposed -= OnTextDocumentDisposed; DocumentClosing?.Invoke(this, null); if (EditorTree != null) { _editorTree.Dispose(); // this will also remove event handlers _editorTree = null; } if (DocumentClosing != null) { foreach (EventHandler <EventArgs> eh in DocumentClosing.GetInvocationList()) { Debug.Fail(String.Format(CultureInfo.CurrentCulture, "There are still listeners in the EditorDocument.OnDocumentClosing event list: {0}", eh.Target)); DocumentClosing -= eh; } } ServiceManager.RemoveService <REditorDocument>(TextBuffer); TextBuffer = null; }
protected void RaiseDocumentClosingEvent(EnvDTE.Document document) => DocumentClosing?.Invoke(document);
private void OnDocumentClosing(DocumentContent documentContent) { DocumentClosing?.Invoke(documentContent); }