/ src / modules / cmdpal / ext / Microsoft.CmdPal.Ext.System / SystemCommandExtensionProvider.cs
SystemCommandExtensionProvider.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.Ext.System.Helpers;
 6  using Microsoft.CmdPal.Ext.System.Pages;
 7  using Microsoft.CommandPalette.Extensions;
 8  using Microsoft.CommandPalette.Extensions.Toolkit;
 9  
10  namespace Microsoft.CmdPal.Ext.System;
11  
12  public sealed partial class SystemCommandExtensionProvider : CommandProvider
13  {
14      private readonly ICommandItem[] _commands;
15      private static readonly SettingsManager _settingsManager = new();
16      public static readonly SystemCommandPage Page = new(_settingsManager);
17      private readonly FallbackSystemCommandItem _fallbackSystemItem = new(_settingsManager);
18  
19      public SystemCommandExtensionProvider()
20      {
21          DisplayName = Resources.Microsoft_plugin_ext_system_page_name;
22          Id = "com.microsoft.cmdpal.builtin.system";
23          _commands = [
24              new CommandItem(Page)
25              {
26                  Title = Resources.Microsoft_plugin_ext_system_page_title,
27                  Icon = Page.Icon,
28                  MoreCommands = [new CommandContextItem(_settingsManager.Settings.SettingsPage)],
29              },
30          ];
31  
32          Icon = Page.Icon;
33          Settings = _settingsManager.Settings;
34      }
35  
36      public override ICommandItem[] TopLevelCommands()
37      {
38          return _commands;
39      }
40  
41      public override IFallbackCommandItem[] FallbackCommands() => [_fallbackSystemItem];
42  }