/ src / settings-ui / Settings.UI.Library / ColorPickerSettingsVersion1.cs
ColorPickerSettingsVersion1.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;
 6  using System.Text.Json;
 7  using System.Text.Json.Serialization;
 8  using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
 9  
10  namespace Microsoft.PowerToys.Settings.UI.Library
11  {
12      public class ColorPickerSettingsVersion1 : BasePTModuleSettings, ISettingsConfig
13      {
14          public const string ModuleName = "ColorPicker";
15  
16          private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
17          {
18              WriteIndented = true,
19          };
20  
21          [JsonPropertyName("properties")]
22          public ColorPickerPropertiesVersion1 Properties { get; set; }
23  
24          public ColorPickerSettingsVersion1()
25          {
26              Properties = new ColorPickerPropertiesVersion1();
27              Version = "1";
28              Name = ModuleName;
29          }
30  
31          public virtual void Save(SettingsUtils settingsUtils)
32          {
33              // Save settings to file
34              var options = _serializerOptions;
35  
36              ArgumentNullException.ThrowIfNull(settingsUtils);
37  
38              settingsUtils.SaveSettings(JsonSerializer.Serialize(this, options), ModuleName);
39          }
40  
41          public string GetModuleName()
42              => Name;
43  
44          // This can be utilized in the future if the settings.json file is to be modified/deleted.
45          public bool UpgradeSettingsConfiguration()
46              => false;
47      }
48  }