Fixed scanning issue. Updated worker.
Some checks failed
ci / build-test (push) Has been cancelled
ci / publish-image (push) Has been cancelled

This commit is contained in:
2026-02-14 22:47:19 -05:00
parent 340c62d18b
commit a85989a337
14 changed files with 286 additions and 36 deletions

View File

@@ -6,8 +6,31 @@ namespace JSMR.Infrastructure.Integrations.DLSite.Serialization;
public sealed class DictionaryConverter<TKey, TValue> : JsonConverter<Dictionary<TKey, TValue>> where TKey : notnull
{
public override Dictionary<TKey, TValue>? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> JsonSerializer.Deserialize<Dictionary<TKey, TValue>>(ref reader, options);
{
if (reader.TokenType == JsonTokenType.Null)
return null;
if (reader.TokenType == JsonTokenType.StartArray)
{
if (!reader.Read())
throw new JsonException("Unexpected end while reading array.");
if (reader.TokenType != JsonTokenType.EndArray)
throw new JsonException("Non-empty JSON array cannot be converted to Dictionary.");
return [];
}
if (reader.TokenType == JsonTokenType.StartObject)
{
return JsonSerializer.Deserialize<Dictionary<TKey, TValue>>(ref reader, options) ?? [];
}
throw new JsonException($"Unexpected token {reader.TokenType} when reading Dictionary.");
}
public override void Write(Utf8JsonWriter writer, Dictionary<TKey, TValue> value, JsonSerializerOptions options)
=> JsonSerializer.Serialize(writer, value, options);
{
JsonSerializer.Serialize(writer, (IDictionary<TKey, TValue>)value, options);
}
}