ListConverter.cs 702 B

1234567891011121314151617181920212223
  1. using System.Text.Json;
  2. using System.Text.Json.Serialization;
  3. namespace Quadarax.Foundation.Core.Json
  4. {
  5. public class ListConverter<M> : JsonConverter<IList<M>>
  6. {
  7. public override IList<M> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
  8. {
  9. return JsonSerializer.Deserialize<List<M>>(ref reader, options);
  10. }
  11. public override bool CanConvert(Type typeToConvert)
  12. {
  13. return base.CanConvert(typeToConvert);
  14. }
  15. public override void Write(Utf8JsonWriter writer, IList<M> value, JsonSerializerOptions options)
  16. {
  17. throw new NotImplementedException();
  18. }
  19. }
  20. }