mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-30 17:39:07 +08:00
[ImageRsizer] Add support for blanks in height/width fields (#15368)
This commit is contained in:
parent
a1f319afa7
commit
ac4f725433
@ -21,6 +21,11 @@ namespace ImageResizer.Properties
|
||||
public sealed partial class Settings : IDataErrorInfo, INotifyPropertyChanged
|
||||
{
|
||||
private static readonly IFileSystem _fileSystem = new FileSystem();
|
||||
private static readonly JsonSerializerOptions _jsonSerializerOptions = new JsonSerializerOptions
|
||||
{
|
||||
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals,
|
||||
WriteIndented = true,
|
||||
};
|
||||
|
||||
// Used to synchronize access to the settings.json file
|
||||
private static Mutex _jsonMutex = new Mutex();
|
||||
@ -409,7 +414,7 @@ namespace ImageResizer.Properties
|
||||
public void Save()
|
||||
{
|
||||
_jsonMutex.WaitOne();
|
||||
string jsonData = JsonSerializer.Serialize(new SettingsWrapper() { Properties = this });
|
||||
string jsonData = JsonSerializer.Serialize(new SettingsWrapper() { Properties = this }, _jsonSerializerOptions);
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
IFileInfo file = _fileSystem.FileInfo.FromFileName(SettingsPath);
|
||||
@ -442,7 +447,7 @@ namespace ImageResizer.Properties
|
||||
var jsonSettings = new Settings();
|
||||
try
|
||||
{
|
||||
jsonSettings = JsonSerializer.Deserialize<SettingsWrapper>(jsonData)?.Properties;
|
||||
jsonSettings = JsonSerializer.Deserialize<SettingsWrapper>(jsonData, _jsonSerializerOptions)?.Properties;
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user