Example #1
0
        public IEnumerable <object> Load(ISettingsManager settingsManager)
        {
            var section = settingsManager.GetOrCreateSection(SETTINGS_GUID);

            foreach (var o in fileListLoader.Load(section.GetOrCreateSection(FILE_LISTS_SECTION)))
            {
                yield return(o);
            }

            var tgws     = new List <SerializedTabGroupWindow>();
            var tgwsHash = new HashSet <string>();

            foreach (var tgwSection in section.SectionsWithName(TABGROUPWINDOW_SECTION))
            {
                var tgw = SerializedTabGroupWindow.Load(tgwSection);
                yield return(null);

                if (tgwsHash.Contains(tgw.Name))
                {
                    continue;
                }
                tgws.Add(tgw);
            }

            // The files are added to the treeview with a slight delay. Make sure the files have
            // been added to the TV or the node lookup code will fail to find the nodes it needs.
            yield return(LoaderConstants.Delay);

            foreach (var o in fileTabSerializer.Restore(tgws))
            {
                yield return(o);
            }

            fileTabManager.OnTabsLoaded();
        }
Example #2
0
        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);
        }