This commit is contained in:
Zeeshaun
2026-03-13 09:11:35 -05:00
parent f004c8205a
commit c2d6bda458
197 changed files with 14970 additions and 0 deletions
@@ -0,0 +1,25 @@
using System;
using System.Globalization;
using System.Numerics;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace LCU.Library.Internal.DocumentModels.Converter;
public class BigIntegerConverter : JsonConverter<BigInteger>
{
public override BigInteger Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType != JsonTokenType.Number)
throw new JsonException($"Found token {reader.TokenType} but expected token {JsonTokenType.Number}");
using var doc = JsonDocument.ParseValue(ref reader);
return BigInteger.Parse(doc.RootElement.GetRawText(), NumberFormatInfo.InvariantInfo);
}
public override void Write(Utf8JsonWriter writer, BigInteger value, JsonSerializerOptions options)
{
var s = value.ToString(NumberFormatInfo.InvariantInfo);
using var doc = JsonDocument.Parse(s);
doc.WriteTo(writer);
}
}