2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-05 17:39:39 -04:00
pulsar/ObservatoryFramework/JournalInvalidDoubleConverter.cs
Ben Parsons efd0b3e0c0 Journals Now processed in own thread
Some invalid journal data is now handled
Journals now use polymorphic deserialization
Added Event names to all journal events
Remove unused controllers
2024-05-24 19:30:12 +10:00

21 lines
579 B
C#

using System.Text.Json;
using System.Text.Json.Serialization;
namespace Observatory.Framework;
public class JournalInvalidDoubleConverter : JsonConverter<double>
{
public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var success = reader.TryGetDouble(out var value);
if (success)
return value;
return 0;
}
public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value, options);
}
}