Switch BlockCypherDateTimeOffsetJsonConverter from 'JsonConverter' to 'JsonConverter<T>'
MODIFY
WalletWasabi/JsonConverters/BlockCypherDateTimeOffsetJsonConverter.cs
WalletWasabi/JsonConverters/BlockCypherDateTimeOffsetJsonConverter.cs
@@ -4,22 +4,16 @@ using System.Globalization;
namespace WalletWasabi.JsonConverters
{
- public class BlockCypherDateTimeOffsetJsonConverter : JsonConverter
+ public class BlockCypherDateTimeOffsetJsonConverter : JsonConverter<DateTimeOffset>
{
/// <inheritdoc />
- public override bool CanConvert(Type objectType)
- {
- return objectType == typeof(DateTimeOffset);
- }
-
- /// <inheritdoc />
- public override object? ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ public override DateTimeOffset ReadJson(JsonReader reader, Type objectType, DateTimeOffset existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var value = reader.Value as string;
if (string.IsNullOrWhiteSpace(value))
{
- return null;
+ return default;
}
string time = value.Trim();
@@ -27,9 +21,9 @@ namespace WalletWasabi.JsonConverters
}
/// <inheritdoc />
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, DateTimeOffset value, JsonSerializer serializer)
{
- writer.WriteValue(((DateTimeOffset)value).ToString(CultureInfo.InvariantCulture));
+ writer.WriteValue(value.ToString(CultureInfo.InvariantCulture));
}
}
}

Switch BlockCypherDateTimeOffsetJsonConverter from 'JsonConverter' to 'JsonConverter<T>'