mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Proper use of serialization routines
This commit is contained in:
@@ -3,9 +3,9 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using Microsoft.PowerToys.Settings.UI.Library;
|
using Microsoft.PowerToys.Settings.UI.Library;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
#pragma warning disable CS8602 // Dereference of a possibly null reference.
|
#pragma warning disable CS8602 // Dereference of a possibly null reference.
|
||||||
@@ -47,7 +47,8 @@ namespace Espresso.Shell.Core
|
|||||||
// Set indefinite keep awake.
|
// Set indefinite keep awake.
|
||||||
var currentSettings = ModuleSettings.GetSettings<EspressoSettings>(text);
|
var currentSettings = ModuleSettings.GetSettings<EspressoSettings>(text);
|
||||||
currentSettings.Properties.Mode = EspressoMode.INDEFINITE;
|
currentSettings.Properties.Mode = EspressoMode.INDEFINITE;
|
||||||
ModuleSettings.SaveSettings(JsonConvert.SerializeObject(currentSettings), text);
|
|
||||||
|
ModuleSettings.SaveSettings(JsonSerializer.Serialize(currentSettings), text);
|
||||||
},
|
},
|
||||||
(hours, minutes) => {
|
(hours, minutes) => {
|
||||||
// Set timed keep awake.
|
// Set timed keep awake.
|
||||||
@@ -56,7 +57,7 @@ namespace Espresso.Shell.Core
|
|||||||
currentSettings.Properties.Hours.Value = hours;
|
currentSettings.Properties.Hours.Value = hours;
|
||||||
currentSettings.Properties.Minutes.Value = minutes;
|
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);
|
var currentSettings = ModuleSettings.GetSettings<EspressoSettings>(text);
|
||||||
currentSettings.Properties.KeepDisplayOn = settings.Properties.KeepDisplayOn;
|
currentSettings.Properties.KeepDisplayOn = settings.Properties.KeepDisplayOn;
|
||||||
|
|
||||||
ModuleSettings.SaveSettings(JsonConvert.SerializeObject(currentSettings), text);
|
ModuleSettings.SaveSettings(JsonSerializer.Serialize(currentSettings), text);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
<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="NLog" Version="4.7.9" />
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20071.2" />
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20071.2" />
|
||||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
using Espresso.Shell.Core;
|
using Espresso.Shell.Core;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
using Microsoft.PowerToys.Settings.UI.Library;
|
using Microsoft.PowerToys.Settings.UI.Library;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using System;
|
using System;
|
||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
|
|||||||
Reference in New Issue
Block a user