Add JSON message writer

Closes #103
This commit is contained in:
Alexey Golub
2020-02-03 17:47:42 +02:00
parent 9fa40dca00
commit 9f6090b3af
9 changed files with 302 additions and 26 deletions

View File

@@ -1,4 +1,6 @@
using System.Text;
using System;
using System.Text;
using System.Text.Json;
namespace DiscordChatExporter.Core.Rendering.Internal
{
@@ -17,5 +19,25 @@ namespace DiscordChatExporter.Core.Rendering.Internal
return builder;
}
public static void WriteString(this Utf8JsonWriter writer, string propertyName, DateTimeOffset? value)
{
writer.WritePropertyName(propertyName);
if (value != null)
writer.WriteStringValue(value.Value);
else
writer.WriteNullValue();
}
public static void WriteNumber(this Utf8JsonWriter writer, string propertyName, int? value)
{
writer.WritePropertyName(propertyName);
if (value != null)
writer.WriteNumberValue(value.Value);
else
writer.WriteNullValue();
}
}
}