mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Core - Moved JSON calls into a helper
This commit is contained in:
1 parent
190d64b497
commit
a5e2dc81a4
12 files changed
+125
-72
No files matched your search
@@ -29,7 +29,7 @@ namespace Artemis.Core
|
||||
Name = pluginSettingEntity.Name;
|
||||
try
|
||||
{
|
||||
_value = JsonConvert.DeserializeObject<T>(pluginSettingEntity.Value, Constants.JsonConvertSettings);
|
||||
_value = CoreJson.DeserializeObject<T>(pluginSettingEntity.Value)!;
|
||||
}
|
||||
catch (JsonReaderException)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// Determines whether the setting has been changed
|
||||
/// </summary>
|
||||
public bool HasChanged => JsonConvert.SerializeObject(Value, Constants.JsonConvertSettings) != _pluginSettingEntity.Value;
|
||||
public bool HasChanged => CoreJson.SerializeObject(Value) != _pluginSettingEntity.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether changes must automatically be saved
|
||||
@@ -79,7 +79,7 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public void RejectChanges()
|
||||
{
|
||||
Value = JsonConvert.DeserializeObject<T>(_pluginSettingEntity.Value, Constants.JsonConvertSettings);
|
||||
Value = CoreJson.DeserializeObject<T>(_pluginSettingEntity.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +90,7 @@ namespace Artemis.Core
|
||||
if (!HasChanged)
|
||||
return;
|
||||
|
||||
_pluginSettingEntity.Value = JsonConvert.SerializeObject(Value, Constants.JsonConvertSettings);
|
||||
_pluginSettingEntity.Value = CoreJson.SerializeObject(Value);
|
||||
_pluginRepository.SaveSetting(_pluginSettingEntity);
|
||||
OnSettingSaved();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Artemis.Core
|
||||
{
|
||||
Name = name,
|
||||
PluginGuid = Plugin.Guid,
|
||||
Value = JsonConvert.SerializeObject(defaultValue, Constants.JsonConvertSettings)
|
||||
Value = CoreJson.SerializeObject(defaultValue)
|
||||
};
|
||||
_pluginRepository.AddSetting(settingEntity);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user