mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-04-05 17:37:54 +08:00
23 lines
767 B
C#
23 lines
767 B
C#
using System;
|
|
using System.Globalization;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace System.Text.Json.Converters
|
|
{
|
|
public class CommonDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
|
|
{
|
|
private readonly JsonConverter<DateTimeOffset?> _converter = new CommonNullableDateTimeOffsetConverter();
|
|
|
|
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
return _converter.Read(ref reader, typeToConvert, options) ?? default;
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
|
|
{
|
|
_converter.Write(writer, value, options);
|
|
}
|
|
}
|
|
}
|