Settings.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 System.Collections.Generic; 6 using Microsoft.CmdPal.Ext.Apps.Helpers; 7 8 namespace Microsoft.CmdPal.Ext.Apps.UnitTests; 9 10 public class Settings : ISettingsInterface 11 { 12 private readonly bool enableStartMenuSource; 13 private readonly bool enableDesktopSource; 14 private readonly bool enableRegistrySource; 15 private readonly bool enablePathEnvironmentVariableSource; 16 private readonly List<string> programSuffixes; 17 private readonly List<string> runCommandSuffixes; 18 19 public Settings( 20 bool enableStartMenuSource = true, 21 bool enableDesktopSource = true, 22 bool enableRegistrySource = true, 23 bool enablePathEnvironmentVariableSource = true, 24 List<string> programSuffixes = null, 25 List<string> runCommandSuffixes = null) 26 { 27 this.enableStartMenuSource = enableStartMenuSource; 28 this.enableDesktopSource = enableDesktopSource; 29 this.enableRegistrySource = enableRegistrySource; 30 this.enablePathEnvironmentVariableSource = enablePathEnvironmentVariableSource; 31 this.programSuffixes = programSuffixes ?? new List<string> { "bat", "appref-ms", "exe", "lnk", "url" }; 32 this.runCommandSuffixes = runCommandSuffixes ?? new List<string> { "bat", "appref-ms", "exe", "lnk", "url", "cpl", "msc" }; 33 } 34 35 public bool EnableStartMenuSource => enableStartMenuSource; 36 37 public bool EnableDesktopSource => enableDesktopSource; 38 39 public bool EnableRegistrySource => enableRegistrySource; 40 41 public bool EnablePathEnvironmentVariableSource => enablePathEnvironmentVariableSource; 42 43 public List<string> ProgramSuffixes => programSuffixes; 44 45 public List<string> RunCommandSuffixes => runCommandSuffixes; 46 47 public static Settings CreateDefaultSettings() => new Settings(); 48 49 public static Settings CreateDisabledSourcesSettings() => new Settings( 50 enableStartMenuSource: false, 51 enableDesktopSource: false, 52 enableRegistrySource: false, 53 enablePathEnvironmentVariableSource: false); 54 55 public static Settings CreateCustomSuffixesSettings() => new Settings( 56 programSuffixes: new List<string> { "exe", "bat" }, 57 runCommandSuffixes: new List<string> { "exe", "bat", "cmd" }); 58 }