/ src / modules / cmdpal / ext / Microsoft.CmdPal.Ext.WindowsSettings / WindowsSettingsCommandsProvider.cs
WindowsSettingsCommandsProvider.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.WindowsSettings.Helpers; 6 using Microsoft.CmdPal.Ext.WindowsSettings.Pages; 7 using Microsoft.CmdPal.Ext.WindowsSettings.Properties; 8 using Microsoft.CommandPalette.Extensions; 9 using Microsoft.CommandPalette.Extensions.Toolkit; 10 11 namespace Microsoft.CmdPal.Ext.WindowsSettings; 12 13 public sealed partial class WindowsSettingsCommandsProvider : CommandProvider 14 { 15 private readonly CommandItem _searchSettingsListItem; 16 17 #pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. 18 private readonly WindowsSettings.Classes.WindowsSettings? _windowsSettings; 19 #pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. 20 21 private readonly FallbackWindowsSettingsItem _fallback; 22 23 public WindowsSettingsCommandsProvider() 24 { 25 Id = "com.microsoft.cmdpal.builtin.windowssettings"; 26 DisplayName = Resources.WindowsSettingsProvider_DisplayName; 27 Icon = Icons.WindowsSettingsIcon; 28 29 _windowsSettings = JsonSettingsListHelper.ReadAllPossibleSettings(); 30 _searchSettingsListItem = new CommandItem(new WindowsSettingsListPage(_windowsSettings)) 31 { 32 Title = Resources.settings_title, 33 }; 34 _fallback = new(_windowsSettings); 35 36 UnsupportedSettingsHelper.FilterByBuild(_windowsSettings); 37 38 TranslationHelper.TranslateAllSettings(_windowsSettings); 39 WindowsSettingsPathHelper.GenerateSettingsPathValues(_windowsSettings); 40 } 41 42 public override ICommandItem[] TopLevelCommands() 43 { 44 return [ 45 _searchSettingsListItem 46 ]; 47 } 48 49 public override IFallbackCommandItem[] FallbackCommands() => [_fallback]; 50 }