|
@@ -1,10 +1,11 @@
|
|
|
using InABox.Core;
|
|
|
-using Newtonsoft.Json;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
+using System.Text.Json;
|
|
|
+using System.Text.Json.Serialization;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace InABox.Wpf.Dashboard;
|
|
@@ -20,7 +21,8 @@ public class DynamicDashboard
|
|
|
|
|
|
private string _presenterProperties = "";
|
|
|
|
|
|
- [JsonProperty(Order = 1, PropertyName = "PresenterProperties")]
|
|
|
+ [JsonPropertyOrder(1)]
|
|
|
+ [JsonPropertyName("PresenterProperties")]
|
|
|
private string PresenterProperties
|
|
|
{
|
|
|
get => DataPresenter is not null ? Serialization.Serialize(DataPresenter.Properties) : "";
|
|
@@ -30,7 +32,8 @@ public class DynamicDashboard
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [JsonProperty(Order = 2, PropertyName = "PresenterType")]
|
|
|
+ [JsonPropertyOrder(2)]
|
|
|
+ [JsonPropertyName("PresenterType")]
|
|
|
private Type? PresenterType
|
|
|
{
|
|
|
get => DataPresenter?.GetType();
|
|
@@ -83,21 +86,21 @@ public static class DynamicDashboardUtils
|
|
|
return _presenterTypes;
|
|
|
}
|
|
|
|
|
|
- private static JsonSerializerSettings SerializationSettings()
|
|
|
+ private static JsonSerializerOptions SerializationSettings()
|
|
|
{
|
|
|
var settings = Serialization.CreateSerializerSettings();
|
|
|
- settings.TypeNameHandling = TypeNameHandling.Auto;
|
|
|
+ settings.Converters.Add(new PolymorphicConverter());
|
|
|
return settings;
|
|
|
}
|
|
|
|
|
|
public static string Serialize(DynamicDashboard data)
|
|
|
{
|
|
|
- return JsonConvert.SerializeObject(data, typeof(DynamicDashboard), SerializationSettings());
|
|
|
+ return JsonSerializer.Serialize(data, typeof(DynamicDashboard), SerializationSettings());
|
|
|
}
|
|
|
|
|
|
public static DynamicDashboard? Deserialize(string? json)
|
|
|
{
|
|
|
if (json.IsNullOrWhiteSpace()) return null;
|
|
|
- return JsonConvert.DeserializeObject<DynamicDashboard>(json, SerializationSettings())!;
|
|
|
+ return JsonSerializer.Deserialize<DynamicDashboard>(json, SerializationSettings())!;
|
|
|
}
|
|
|
}
|