public void Dispose() { foreach (var document in documentTabService.DocumentTreeView.DocumentService.GetDocuments()) { originalDocuments.Remove(document); } var removedDocuments = originalDocuments.ToArray(); // Documents are added with a delay to the TV. Make sure our code executes after all // of the pending events. documentTabService.DocumentTreeView.AddAction(() => { documentTabService.disable_DocumentCollectionChanged = old_disable_DocumentCollectionChanged; if (removedDocuments.Length > 0) { documentTabService.CallDocumentCollectionChanged(NotifyDocumentCollectionChangedEventArgs.CreateRemove(removedDocuments, null)); } }); }
public void Remove(IDsDocumentNameKey key) { Debug.Assert(key != null); if (key == null) { return; } IDsDocument removedDocument; lock (lockObj) removedDocument = Remove_NoLock(key); Debug.Assert(removedDocument != null); if (removedDocument != null) { CallCollectionChanged(NotifyDocumentCollectionChangedEventArgs.CreateRemove(removedDocument, null)); } }
public void Remove(IEnumerable <IDsDocument> documents) { var removedDocuments = new List <IDsDocument>(); lock (lockObj) { var dict = new Dictionary <IDsDocument, int>(); int i = 0; foreach (var n in this.documents) { dict[n] = i++; } var list = new List <Tuple <IDsDocument, int> >(documents.Select(a => { int j; bool b = dict.TryGetValue(a, out j); Debug.Assert(b); return(Tuple.Create(a, b ? j : -1)); })); list.Sort((a, b) => b.Item2.CompareTo(a.Item2)); foreach (var t in list) { if (t.Item2 < 0) { continue; } Debug.Assert((uint)t.Item2 < (uint)this.documents.Count); Debug.Assert(this.documents[t.Item2] == t.Item1); this.documents.RemoveAt(t.Item2); removedDocuments.Add(t.Item1); } } if (removedDocuments.Count > 0) { CallCollectionChanged(NotifyDocumentCollectionChangedEventArgs.CreateRemove(removedDocuments.ToArray(), null)); } }