public bool Load(FileList fileList, IDnSpyFileLoader dnSpyFileLoader) { const bool isReload = false; if (dnSpyFileLoader == null) { dnSpyFileLoader = new DefaultDnSpyFileLoader(fileTabManager.FileTreeView.FileManager); } if (!CanLoad) { return(false); } if (!CheckCanLoad(isReload)) { return(false); } if (fileList != fileListManager.SelectedFileList) { SaveCurrentFilesToList(); } NotifyBeforeLoad(isReload); using (DisableSaveToList()) { fileTabManager.CloseAll(); fileTabManager.FileTreeView.FileManager.Clear(); dnSpyFileLoader.Load(fileList.Files.Select(a => new FileToLoad(a))); } NotifyAfterLoad(isReload); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { GC.Collect(); GC.WaitForPendingFinalizers(); })); return(true); }
public bool Reload(IDnSpyFileLoader dnSpyFileLoader) { const bool isReload = true; if (dnSpyFileLoader == null) { dnSpyFileLoader = new DefaultDnSpyFileLoader(fileTabManager.FileTreeView.FileManager); } if (!CanReload) { return(false); } if (!CheckCanLoad(isReload)) { return(false); } SaveCurrentFilesToList(); NotifyBeforeLoad(isReload); var tgws = fileTabSerializer.SaveTabs(); using (DisableSaveToList()) using (fileTabManager.OnReloadAll()) { fileTabManager.CloseAll(); fileTabManager.FileTreeView.FileManager.Clear(); var files = fileListManager.SelectedFileList.Files.Select(a => new FileToLoad(a)).ToList(); foreach (var tgw in tgws) { foreach (var g in tgw.TabGroups) { foreach (var t in g.Tabs) { foreach (var f in t.AutoLoadedFiles) { files.Add(new FileToLoad(f, true)); } } } } dnSpyFileLoader.Load(files); } NotifyAfterLoad(isReload); // The files in the TV is loaded with a delay so make sure we delay before restoring // or the code that tries to find the nodes might fail to find them. disableLoadAndReload = true; Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { GC.Collect(); GC.WaitForPendingFinalizers(); foreach (var o in fileTabSerializer.Restore(tgws)) { } disableLoadAndReload = false; })); return(true); }
public bool Reload(IDnSpyFileLoader dnSpyFileLoader) { const bool isReload = true; if (dnSpyFileLoader == null) dnSpyFileLoader = new DefaultDnSpyFileLoader(fileTabManager.FileTreeView.FileManager); if (!CanReload) return false; if (!CheckCanLoad(isReload)) return false; SaveCurrentFilesToList(); NotifyBeforeLoad(isReload); var tgws = fileTabSerializer.SaveTabs(); using (DisableSaveToList()) using (fileTabManager.OnReloadAll()) { fileTabManager.CloseAll(); fileTabManager.FileTreeView.FileManager.Clear(); var files = fileListManager.SelectedFileList.Files.Select(a => new FileToLoad(a)).ToList(); foreach (var tgw in tgws) { foreach (var g in tgw.TabGroups) { foreach (var t in g.Tabs) { foreach (var f in t.AutoLoadedFiles) files.Add(new FileToLoad(f, true)); } } } dnSpyFileLoader.Load(files); } NotifyAfterLoad(isReload); // The files in the TV is loaded with a delay so make sure we delay before restoring // or the code that tries to find the nodes might fail to find them. disableLoadAndReload = true; Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { GC.Collect(); GC.WaitForPendingFinalizers(); foreach (var o in fileTabSerializer.Restore(tgws)) { } disableLoadAndReload = false; })); return true; }
public bool Load(FileList fileList, IDnSpyFileLoader dnSpyFileLoader) { const bool isReload = false; if (dnSpyFileLoader == null) dnSpyFileLoader = new DefaultDnSpyFileLoader(fileTabManager.FileTreeView.FileManager); if (!CanLoad) return false; if (!CheckCanLoad(isReload)) return false; if (fileList != fileListManager.SelectedFileList) SaveCurrentFilesToList(); NotifyBeforeLoad(isReload); using (DisableSaveToList()) { fileTabManager.CloseAll(); fileTabManager.FileTreeView.FileManager.Clear(); dnSpyFileLoader.Load(fileList.Files.Select(a => new FileToLoad(a))); } NotifyAfterLoad(isReload); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { GC.Collect(); GC.WaitForPendingFinalizers(); })); return true; }