public void Dispose() { foreach (var file in fileTabManager.FileTreeView.FileManager.GetFiles()) { originalFiles.Remove(file); } var removedFiles = originalFiles.ToArray(); // Files are added with a delay to the TV. Make sure our code executes after all // of the pending events. fileTabManager.fileTreeView.AddAction(() => { fileTabManager.disable_FileCollectionChanged = old_disable_FileCollectionChanged; if (removedFiles.Length > 0) { fileTabManager.CallFileCollectionChanged(NotifyFileCollectionChangedEventArgs.CreateRemove(removedFiles, null)); } }); }
public void Remove(IDnSpyFilenameKey key) { Debug.Assert(key != null); if (key == null) { return; } IDnSpyFile removedFile; lock (lockObj) removedFile = Remove_NoLock(key); Debug.Assert(removedFile != null); if (removedFile != null) { CallCollectionChanged(NotifyFileCollectionChangedEventArgs.CreateRemove(removedFile, null)); } }
public void Remove(IEnumerable <IDnSpyFile> files) { var removedFiles = new List <IDnSpyFile>(); lock (lockObj) { var dict = new Dictionary <IDnSpyFile, int>(); int i = 0; foreach (var n in this.files) { dict[n] = i++; } var list = new List <Tuple <IDnSpyFile, int> >(files.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.files.Count); Debug.Assert(this.files[t.Item2] == t.Item1); this.files.RemoveAt(t.Item2); removedFiles.Add(t.Item1); } } if (removedFiles.Count > 0) { CallCollectionChanged(NotifyFileCollectionChangedEventArgs.CreateRemove(removedFiles.ToArray(), null)); } }