/ src / modules / cmdpal / Microsoft.CmdPal.UI.ViewModels / CommandPaletteHost.cs
CommandPaletteHost.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.Common.Services;
 6  using Microsoft.CmdPal.Core.ViewModels;
 7  using Microsoft.CommandPalette.Extensions;
 8  
 9  namespace Microsoft.CmdPal.UI.ViewModels;
10  
11  public sealed partial class CommandPaletteHost : AppExtensionHost, IExtensionHost
12  {
13      // Static singleton, so that we can access this from anywhere
14      // Post MVVM - this should probably be like, a dependency injection thing.
15      public static CommandPaletteHost Instance { get; } = new();
16  
17      public IExtensionWrapper? Extension { get; }
18  
19      private readonly ICommandProvider? _builtInProvider;
20  
21      private CommandPaletteHost()
22      {
23      }
24  
25      public CommandPaletteHost(IExtensionWrapper source)
26      {
27          Extension = source;
28      }
29  
30      public CommandPaletteHost(ICommandProvider builtInProvider)
31      {
32          _builtInProvider = builtInProvider;
33      }
34  
35      public override string? GetExtensionDisplayName()
36      {
37          return Extension?.ExtensionDisplayName ?? _builtInProvider?.DisplayName ?? _builtInProvider?.Id;
38      }
39  }