diff --git a/src/Aeon.Acquisition/Aeon.Acquisition.csproj b/src/Aeon.Acquisition/Aeon.Acquisition.csproj index f42ee90..815e7c9 100644 --- a/src/Aeon.Acquisition/Aeon.Acquisition.csproj +++ b/src/Aeon.Acquisition/Aeon.Acquisition.csproj @@ -6,7 +6,7 @@ Bonsai Rx Project Aeon Acquisition net472 0.5.0 - build231204 + build231205 diff --git a/src/Aeon.Acquisition/StateRecovery.cs b/src/Aeon.Acquisition/StateRecovery.cs index 8aa17e5..ce59573 100644 --- a/src/Aeon.Acquisition/StateRecovery.cs +++ b/src/Aeon.Acquisition/StateRecovery.cs @@ -1,7 +1,5 @@ -using System; -using System.IO; -using System.Xml; -using System.Xml.Serialization; +using System.IO; +using Newtonsoft.Json; namespace Aeon.Acquisition { @@ -14,11 +12,8 @@ static string GetFileName(string name) => !string.IsNullOrEmpty(name) public static void Serialize(string name, TState value) { var fileName = GetFileName(name); - var serializer = new XmlSerializer(typeof(TState)); - using (var writer = XmlWriter.Create(fileName, new XmlWriterSettings { Indent = true })) - { - serializer.Serialize(writer, value); - } + var json = JsonConvert.SerializeObject(value, Formatting.Indented); + File.WriteAllText(fileName, json); } public static TState Deserialize(string name) @@ -29,15 +24,12 @@ public static TState Deserialize(string name) return new TState(); } - var serializer = new XmlSerializer(typeof(TState)); + var json = File.ReadAllText(fileName); try { - using (var reader = XmlReader.Create(fileName)) - { - return (TState)serializer.Deserialize(reader); - } + return JsonConvert.DeserializeObject(json); } - catch (InvalidOperationException) + catch (JsonException) { return new TState(); }