PowerToysAppHostService.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Microsoft.CmdPal.Core.ViewModels; 6 using Microsoft.CmdPal.UI.ViewModels; 7 8 // To learn more about WinUI, the WinUI project structure, 9 // and more about our project templates, see: http://aka.ms/winui-project-info. 10 namespace Microsoft.CmdPal.UI; 11 12 internal sealed class PowerToysAppHostService : IAppHostService 13 { 14 public AppExtensionHost GetDefaultHost() 15 { 16 return CommandPaletteHost.Instance; 17 } 18 19 public AppExtensionHost GetHostForCommand(object? context, AppExtensionHost? currentHost) 20 { 21 AppExtensionHost? topLevelHost = null; 22 if (context is TopLevelViewModel topLevelViewModel) 23 { 24 topLevelHost = topLevelViewModel.ExtensionHost; 25 } 26 27 return topLevelHost ?? currentHost ?? CommandPaletteHost.Instance; 28 } 29 }