Proper use of serialization routines

This commit is contained in:
Den Delimarsky
2021-05-10 18:46:39 -07:00
parent 8013664eef
commit 61a787844b
3 changed files with 5 additions and 6 deletions

View File

@@ -3,9 +3,9 @@
// See the LICENSE file in the project root for more information.
using Microsoft.PowerToys.Settings.UI.Library;
using Newtonsoft.Json;
using System;
using System.Drawing;
using System.Text.Json;
using System.Windows.Forms;
#pragma warning disable CS8602 // Dereference of a possibly null reference.
@@ -47,7 +47,8 @@ namespace Espresso.Shell.Core
// Set indefinite keep awake.
var currentSettings = ModuleSettings.GetSettings<EspressoSettings>(text);
currentSettings.Properties.Mode = EspressoMode.INDEFINITE;
ModuleSettings.SaveSettings(JsonConvert.SerializeObject(currentSettings), text);
ModuleSettings.SaveSettings(JsonSerializer.Serialize(currentSettings), text);
},
(hours, minutes) => {
// Set timed keep awake.
@@ -56,7 +57,7 @@ namespace Espresso.Shell.Core
currentSettings.Properties.Hours.Value = hours;
currentSettings.Properties.Minutes.Value = minutes;
ModuleSettings.SaveSettings(JsonConvert.SerializeObject(currentSettings), text);
ModuleSettings.SaveSettings(JsonSerializer.Serialize(currentSettings), text);
},
() =>
{
@@ -64,7 +65,7 @@ namespace Espresso.Shell.Core
var currentSettings = ModuleSettings.GetSettings<EspressoSettings>(text);
currentSettings.Properties.KeepDisplayOn = settings.Properties.KeepDisplayOn;
ModuleSettings.SaveSettings(JsonConvert.SerializeObject(currentSettings), text);
ModuleSettings.SaveSettings(JsonSerializer.Serialize(currentSettings), text);
});
}

View File

@@ -38,7 +38,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="4.7.9" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20071.2" />
<PackageReference Include="System.Reactive" Version="5.0.0" />

View File

@@ -5,7 +5,6 @@
using Espresso.Shell.Core;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library;
using Newtonsoft.Json;
using NLog;
using System;
using System.CommandLine;