You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DiscordChatExporter/DiscordChatExporter.Core/Exporting/Writers/MessageWriter.cs

36 lines
962 B

5 years ago
using System;
using System.IO;
using System.Threading.Tasks;
4 years ago
using DiscordChatExporter.Core.Discord.Data;
5 years ago
4 years ago
namespace DiscordChatExporter.Core.Exporting.Writers
5 years ago
{
4 years ago
internal abstract class MessageWriter : IAsyncDisposable
5 years ago
{
protected Stream Stream { get; }
5 years ago
4 years ago
protected ExportContext Context { get; }
5 years ago
3 years ago
public long MessagesWritten { get; private set; }
public long BytesWritten => Stream.Length;
4 years ago
protected MessageWriter(Stream stream, ExportContext context)
5 years ago
{
Stream = stream;
5 years ago
Context = context;
}
public virtual ValueTask WritePreambleAsync() => default;
5 years ago
3 years ago
public virtual ValueTask WriteMessageAsync(Message message)
{
MessagesWritten++;
return default;
}
5 years ago
public virtual ValueTask WritePostambleAsync() => default;
5 years ago
public virtual async ValueTask DisposeAsync() => await Stream.DisposeAsync();
5 years ago
}
}