/// <summary>
		/// Creates a <see cref="NotifyFileCollectionType.Add"/> instance
		/// </summary>
		/// <param name="file">Added file</param>
		/// <param name="data">Data to send to listeners</param>
		/// <returns></returns>
		public static NotifyFileCollectionChangedEventArgs CreateAdd(IDnSpyFile file, object data) {
			if (file == null)
				throw new ArgumentNullException();
			var e = new NotifyFileCollectionChangedEventArgs();
			e.Type = NotifyFileCollectionType.Add;
			e.Files = new IDnSpyFile[] { file };
			e.Data = data;
			return e;
		}
		/// <summary>
		/// Creates a <see cref="NotifyFileCollectionType.Clear"/> instance
		/// </summary>
		/// <param name="clearedFiles">All cleared files</param>
		/// <param name="data">Data to send to listeners</param>
		/// <returns></returns>
		public static NotifyFileCollectionChangedEventArgs CreateClear(IDnSpyFile[] clearedFiles, object data) {
			if (clearedFiles == null)
				throw new ArgumentNullException();
			var e = new NotifyFileCollectionChangedEventArgs();
			e.Type = NotifyFileCollectionType.Clear;
			e.Files = clearedFiles;
			e.Data = data;
			return e;
		}
示例#3
0
		void FileManager_CollectionChanged(object sender, NotifyFileCollectionChangedEventArgs e) {
			switch (e.Type) {
			case NotifyFileCollectionType.Clear:
				vmSearch.Clear();
				break;

			case NotifyFileCollectionType.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.Files.Any(a => !a.IsAutoLoaded))
					vmSearch.Restart();
				break;

			case NotifyFileCollectionType.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;
			}
		}
示例#4
0
		void FileManager_CollectionChanged(object sender, NotifyFileCollectionChangedEventArgs e) {
			switch (e.Type) {
			case NotifyFileCollectionType.Clear:
				ClearAll();
				break;

			case NotifyFileCollectionType.Add:
				AnalyzerTreeNodeData.HandleAssemblyListChanged(treeView.Root, new IDnSpyFile[0], e.Files);
				break;

			case NotifyFileCollectionType.Remove:
				AnalyzerTreeNodeData.HandleAssemblyListChanged(treeView.Root, e.Files, new IDnSpyFile[0]);
				break;

			default:
				break;
			}
		}
		/// <summary>
		/// Creates a <see cref="NotifyFileCollectionType.Remove"/> instance
		/// </summary>
		/// <param name="files">Removed files</param>
		/// <param name="data">Data to send to listeners</param>
		/// <returns></returns>
		public static NotifyFileCollectionChangedEventArgs CreateRemove(IDnSpyFile[] files, object data) {
			if (files == null)
				throw new ArgumentNullException();
			var e = new NotifyFileCollectionChangedEventArgs();
			e.Type = NotifyFileCollectionType.Remove;
			e.Files = files;
			e.Data = data;
			return e;
		}
示例#6
0
        void FileTabManager_FileCollectionChanged(object sender, NotifyFileCollectionChangedEventArgs e)
        {
            switch (e.Type) {
            case NotifyFileCollectionType.Clear:
            case NotifyFileCollectionType.Remove:
                var existing = new HashSet<SerializedDnModule>(fileTabManager.FileTreeView.GetAllModuleNodes().Select(a => a.DnSpyFile.ToSerializedDnModule()));
                var removed = new HashSet<SerializedDnModule>(e.Files.Select(a => a.ToSerializedDnModule()));
                existing.Remove(new SerializedDnModule());
                removed.Remove(new SerializedDnModule());
                object orbArg = null;
                if (OnRemoveBreakpoints != null)
                    orbArg = OnRemoveBreakpoints(orbArg);
                foreach (var ilbp in ILCodeBreakpoints) {
                    // Don't auto-remove BPs in dynamic modules since they have no disk file. The
                    // user must delete these him/herself.
                    if (ilbp.SerializedDnToken.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.SerializedDnToken.Module))
                        continue;

                    if (removed.Contains(ilbp.SerializedDnToken.Module))
                        Remove(ilbp);
                }
                if (OnRemoveBreakpoints != null)
                    OnRemoveBreakpoints(orbArg);
                break;

            case NotifyFileCollectionType.Add:
                break;
            }
        }
示例#7
0
 void CallCollectionChanged2(NotifyFileCollectionChangedEventArgs eventArgs)
 {
     var c = CollectionChanged;
     if (c != null)
         c(this, eventArgs);
 }
示例#8
0
 void CallCollectionChanged(NotifyFileCollectionChangedEventArgs eventArgs, bool delayLoad = true)
 {
     if (delayLoad && dispatcher != null)
         dispatcher(() => CallCollectionChanged2(eventArgs));
     else
         CallCollectionChanged2(eventArgs);
 }