Restructure solution layout by module
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
namespace StellaOps.Notify.Models;
|
||||
|
||||
internal sealed class Iso8601DurationConverter : JsonConverter<TimeSpan>
|
||||
{
|
||||
public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType is JsonTokenType.String)
|
||||
{
|
||||
var value = reader.GetString();
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return XmlConvert.ToTimeSpan(value);
|
||||
}
|
||||
}
|
||||
|
||||
throw new JsonException("Expected ISO 8601 duration string.");
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options)
|
||||
{
|
||||
var normalized = XmlConvert.ToString(value);
|
||||
writer.WriteStringValue(normalized);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user