diff --git a/ILSpy/Search/SearchPaneModel.cs b/ILSpy/Search/SearchPaneModel.cs index e1c02d531..b71ae1190 100644 --- a/ILSpy/Search/SearchPaneModel.cs +++ b/ILSpy/Search/SearchPaneModel.cs @@ -173,14 +173,14 @@ namespace ILSpy.Search ArgumentNullException.ThrowIfNull(result); if (result.Reference is null) return; - var atm = TryGetAssemblyTreeModel(); + var atm = AppComposition.TryGetExport(); if (atm == null) return; var node = atm.FindTreeNode(result.Reference); if (node == null) return; if (inNewTabPage) - TryGetDockWorkspace()?.OpenNodeInNewTab(node); + AppComposition.TryGetExport()?.OpenNodeInNewTab(node); else atm.SelectedItem = node; } @@ -210,21 +210,21 @@ namespace ILSpy.Search if (string.IsNullOrWhiteSpace(term)) return; - var assemblyTreeModel = TryGetAssemblyTreeModel(); + var assemblyTreeModel = AppComposition.TryGetExport(); var assemblyList = assemblyTreeModel?.AssemblyList; if (assemblyList == null) return; - var language = TryGetLanguage(); + var language = AppComposition.TryGetExport()?.CurrentLanguage; if (language == null) return; - var apiVisibility = TryGetSettings()?.SessionSettings?.LanguageSettings?.ShowApiLevel + var apiVisibility = AppComposition.TryGetExport()?.SessionSettings?.LanguageSettings?.ShowApiLevel ?? ApiVisibility.PublicOnly; var factory = new AvaloniaSearchResultFactory(language); // Capture the comparer at start-of-search (matches WPF SearchPane.xaml.cs:288). // Toggling "Sort results by fitness" mid-run won't reshuffle results already on // screen — it only takes effect on the next search. - var sortComparer = (TryGetSettings()?.DisplaySettings.SortResults ?? true) + var sortComparer = (AppComposition.TryGetExport()?.DisplaySettings.SortResults ?? true) ? SearchResult.ComparerByFitness : SearchResult.ComparerByName; var run = new RunningSearch( @@ -250,52 +250,5 @@ namespace ILSpy.Search IsSearching = false; } - static AssemblyTreeModel? TryGetAssemblyTreeModel() - { - try - { - return AppComposition.Current.GetExport(); - } - catch - { - return null; - } - } - - static Language? TryGetLanguage() - { - try - { - return AppComposition.Current.GetExport().CurrentLanguage; - } - catch - { - return null; - } - } - - static SettingsService? TryGetSettings() - { - try - { - return AppComposition.Current.GetExport(); - } - catch - { - return null; - } - } - - static Docking.DockWorkspace? TryGetDockWorkspace() - { - try - { - return AppComposition.Current.GetExport(); - } - catch - { - return null; - } - } } }