about summary refs log tree commit diff
path: root/LibMatrix.LegacyEvents.EventTypes/LegacyMatrixEvent.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LibMatrix.LegacyEvents.EventTypes/LegacyMatrixEvent.cs (renamed from LibMatrix/LegacyMatrixEvent.cs)28
1 files changed, 26 insertions, 2 deletions
diff --git a/LibMatrix/LegacyMatrixEvent.cs b/LibMatrix.LegacyEvents.EventTypes/LegacyMatrixEvent.cs
index a1ac5db..3cb9ecb 100644
--- a/LibMatrix/LegacyMatrixEvent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/LegacyMatrixEvent.cs
@@ -1,6 +1,7 @@
 #if !DISABLE_LEGACY_EVENTS
 using System.Collections.Frozen;
 using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
 using System.Reflection;
 using System.Text.Json;
 using System.Text.Json.Nodes;
@@ -9,7 +10,6 @@ using ArcaneLibs;
 using ArcaneLibs.Attributes;
 using ArcaneLibs.Extensions;
 using LibMatrix.LegacyEvents.EventTypes;
-using LibMatrix.Extensions;
 
 namespace LibMatrix;
 
@@ -224,4 +224,28 @@ public class StateEventContentPolymorphicTypeInfoResolver : DefaultJsonTypeInfoR
 */
 
 #endregion
-#endif
\ No newline at end of file
+#endif
+
+public class JsonFloatStringConverter : JsonConverter<float> {
+    public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+        => float.Parse(reader.GetString()!);
+
+    public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
+        => writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
+}
+
+public class JsonDoubleStringConverter : JsonConverter<double> {
+    public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+        => double.Parse(reader.GetString()!);
+
+    public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
+        => writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
+}
+
+public class JsonDecimalStringConverter : JsonConverter<decimal> {
+    public override decimal Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+        => decimal.Parse(reader.GetString()!);
+
+    public override void Write(Utf8JsonWriter writer, decimal value, JsonSerializerOptions options)
+        => writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
+}
\ No newline at end of file