Merge branch 'master' into v3.1
大石头 authored at 2024-07-13 19:03:18
985.00 B
Stardust
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using NewLife.Log;

namespace Stardust.Server.Common
{
    internal class JsonConverterForBuilder : JsonConverter<ISpanBuilder>
    {
        public override ISpanBuilder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => JsonSerializer.Deserialize<DefaultSpanBuilder>(ref reader, options);

        public override void Write(Utf8JsonWriter writer, ISpanBuilder value, JsonSerializerOptions options) => JsonSerializer.Serialize(writer, value, options);
    }

    internal class JsonConverterForSpan : JsonConverter<ISpan>
    {
        public override ISpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => JsonSerializer.Deserialize<DefaultSpan>(ref reader, options);

        public override void Write(Utf8JsonWriter writer, ISpan value, JsonSerializerOptions options) => JsonSerializer.Serialize(writer, value, options);
    }
}