20 lines
601 B
C#
20 lines
601 B
C#
using System;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace NzbDrone.Common.Serializer
|
|
{
|
|
public class PolymorphicWriteOnlyJsonConverter<T> : JsonConverter<T>
|
|
{
|
|
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
return JsonSerializer.Deserialize<T>(ref reader, options);
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
|
{
|
|
JsonSerializer.Serialize(writer, value, value.GetType(), options);
|
|
}
|
|
}
|
|
}
|