/// <summary> /// Creates a <see cref="NotifyDocumentCollectionType.Add"/> instance /// </summary> /// <param name="document">Added document</param> /// <param name="data">Data to send to listeners</param> /// <returns></returns> public static NotifyDocumentCollectionChangedEventArgs CreateAdd(IDsDocument document, object data) { if (document == null) throw new ArgumentNullException(nameof(document)); var e = new NotifyDocumentCollectionChangedEventArgs(); e.Type = NotifyDocumentCollectionType.Add; e.Documents = new IDsDocument[] { document }; e.Data = data; return e; }
/// <summary> /// Creates a <see cref="NotifyDocumentCollectionType.Clear"/> instance /// </summary> /// <param name="clearedDocuments">All cleared documents</param> /// <param name="data">Data to send to listeners</param> /// <returns></returns> public static NotifyDocumentCollectionChangedEventArgs CreateClear(IDsDocument[] clearedDocuments, object data) { var e = new NotifyDocumentCollectionChangedEventArgs(); e.Type = NotifyDocumentCollectionType.Clear; e.Documents = clearedDocuments ?? throw new ArgumentNullException(nameof(clearedDocuments)); e.Data = data; return(e); }
/// <summary> /// Creates a <see cref="NotifyDocumentCollectionType.Clear"/> instance /// </summary> /// <param name="clearedDocuments">All cleared documents</param> /// <param name="data">Data to send to listeners</param> /// <returns></returns> public static NotifyDocumentCollectionChangedEventArgs CreateClear(IDsDocument[] clearedDocuments, object data) { if (clearedDocuments == null) throw new ArgumentNullException(nameof(clearedDocuments)); var e = new NotifyDocumentCollectionChangedEventArgs(); e.Type = NotifyDocumentCollectionType.Clear; e.Documents = clearedDocuments; e.Data = data; return e; }
/// <summary> /// Creates a <see cref="NotifyDocumentCollectionType.Remove"/> instance /// </summary> /// <param name="documents">Removed documents</param> /// <param name="data">Data to send to listeners</param> /// <returns></returns> public static NotifyDocumentCollectionChangedEventArgs CreateRemove(IDsDocument[] documents, object data) { var e = new NotifyDocumentCollectionChangedEventArgs(); e.Type = NotifyDocumentCollectionType.Remove; e.Documents = documents ?? throw new ArgumentNullException(nameof(documents)); e.Data = data; return(e); }
/// <summary> /// Creates a <see cref="NotifyDocumentCollectionType.Add"/> instance /// </summary> /// <param name="document">Added document</param> /// <param name="data">Data to send to listeners</param> /// <returns></returns> public static NotifyDocumentCollectionChangedEventArgs CreateAdd(IDsDocument document, object?data) { if (document is null) { throw new ArgumentNullException(nameof(document)); } var e = new NotifyDocumentCollectionChangedEventArgs(new IDsDocument[] { document }); e.Type = NotifyDocumentCollectionType.Add; e.Data = data; return(e); }
void DocumentService_CollectionChanged(object sender, NotifyDocumentCollectionChangedEventArgs e) { switch (e.Type) { case NotifyDocumentCollectionType.Clear: ClearAll(); break; case NotifyDocumentCollectionType.Add: AnalyzerTreeNodeData.HandleAssemblyListChanged(TreeView.Root, Array.Empty<IDsDocument>(), e.Documents); break; case NotifyDocumentCollectionType.Remove: AnalyzerTreeNodeData.HandleAssemblyListChanged(TreeView.Root, e.Documents, Array.Empty<IDsDocument>()); break; default: break; } }
void DocumentTabService_FileCollectionChanged(object sender, NotifyDocumentCollectionChangedEventArgs e) { switch (e.Type) { case NotifyDocumentCollectionType.Clear: case NotifyDocumentCollectionType.Remove: var existing = new HashSet<ModuleId>(documentTabService.DocumentTreeView.GetAllModuleNodes().Select(a => moduleIdProvider.Create(a.Document.ModuleDef))); var removed = new HashSet<ModuleId>(e.Documents.Select(a => moduleIdProvider.Create(a.ModuleDef))); existing.Remove(new ModuleId()); removed.Remove(new ModuleId()); object orbArg = null; if (OnRemoveBreakpoints != null) orbArg = OnRemoveBreakpoints(orbArg); foreach (var ilbp in GetILCodeBreakpoints()) { // Don't auto-remove BPs in dynamic modules since they have no disk file. The // user must delete these him/herself. if (ilbp.MethodToken.Module.IsDynamic) continue; // If the file is still in the TV, don't delete anything. This can happen if // we've loaded an in-memory module and the node just got removed. if (existing.Contains(ilbp.MethodToken.Module)) continue; if (removed.Contains(ilbp.MethodToken.Module)) Remove(ilbp); } OnRemoveBreakpoints?.Invoke(orbArg); break; case NotifyDocumentCollectionType.Add: break; } }
void DocumentService_CollectionChanged(object sender, NotifyDocumentCollectionChangedEventArgs e) { switch (e.Type) { case NotifyDocumentCollectionType.Clear: vmSearch.Clear(); break; case NotifyDocumentCollectionType.Add: // Only restart the search if the file was explicitly loaded by the user. Assembly // resolves shouldn't restart the search since it happens too often. if (e.Documents.Any(a => !a.IsAutoLoaded)) vmSearch.Restart(); break; case NotifyDocumentCollectionType.Remove: // We only need to restart the search if the search has not completed or if any of // the search results contain a reference to the assembly. vmSearch.Restart(); break; default: Debug.Fail("Unknown NotifyFileCollectionType"); break; } }