20240327
This commit is contained in:
parent
9171e6d5e3
commit
b13c15ea40
@ -383,14 +383,15 @@ public class ActionState<T>: ISerializable
|
||||
serializableModel.Value = value.Serialize();
|
||||
|
||||
// Возвращаю сериализованную модель
|
||||
return new SysTextSerializer().Serialize(serializableModel);
|
||||
return new NewtonsoftJsonSerializer().Serialize(serializableModel);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Deserialize (string json)
|
||||
{
|
||||
// Десериализую строку
|
||||
ActionStateSerializable itemSerializable = new SysTextSerializer().Deserialize<ActionStateSerializable>(json) ?? new();
|
||||
ActionStateSerializable itemSerializable =
|
||||
new NewtonsoftJsonSerializer().Deserialize<ActionStateSerializable>(json) ?? new();
|
||||
|
||||
// Создаю модель значения
|
||||
ActionStateSerializableValue value = new();
|
||||
|
@ -75,13 +75,13 @@ public sealed class ActionStateMessage: ISerializable
|
||||
|
||||
#region Реализация интерфейса ISerializable
|
||||
/// <inheritdoc />
|
||||
public string Serialize () => new SysTextSerializer().Serialize(this);
|
||||
public string Serialize () => new NewtonsoftJsonSerializer().Serialize(this);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Deserialize (string json)
|
||||
{
|
||||
// Десериализую строку
|
||||
ActionStateMessage item = new SysTextSerializer().Deserialize<ActionStateMessage>(json) ?? new();
|
||||
ActionStateMessage item = new NewtonsoftJsonSerializer().Deserialize<ActionStateMessage>(json) ?? new();
|
||||
|
||||
// Передаю параметры
|
||||
IsCritical = item.IsCritical;
|
||||
|
@ -1,4 +1,5 @@
|
||||
namespace anbs_cp.Classes;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
namespace anbs_cp.Classes;
|
||||
|
||||
/// <summary>
|
||||
/// Сериализованная модель класса, хранящего в себе состояния действия
|
||||
|
@ -11,5 +11,6 @@ public class NewtonsoftJsonSerializer: ISerializer
|
||||
public string Serialize<T> (T data) => JsonConvert.SerializeObject(data);
|
||||
|
||||
/// <inheritdoc />
|
||||
public T? Deserialize<T> (string json) => JsonConvert.DeserializeObject<T>(json);
|
||||
public T? Deserialize<T>(string json) => JsonConvert.DeserializeObject<T>(json,
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user