namespace StockSharp.Fix.Native; /// /// The base class of the recorder. /// /// /// Initialize . /// /// The stream. /// Text encoding. /// Whether to dispose the stream when this instance is disposed. public abstract class BaseFixWriter(Stream stream, Encoding encoding, bool ownsStream = false) : FixBase(stream, encoding, ownsStream) { private readonly byte[] _buffer = new byte[1]; /// /// To record the value. /// /// value. /// Cancellation token. protected async ValueTask WriteByteAsync(byte value, CancellationToken cancellationToken) { _buffer[0] = value; await Stream.WriteAsync(_buffer, 0, 1, cancellationToken).NoWait(); CalcCheckSum(value); } /// /// To record an array of bytes asynchronously. /// /// Bytes buffer. /// Cancellation token. public async ValueTask WriteBytesAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken) { await Stream.WriteAsync(buffer, cancellationToken).NoWait(); CalcCheckSum(buffer.Span); Dump(buffer.Span); } /// /// Flushes the stream asynchronously. /// /// /// public Task FlushAsync(CancellationToken cancellationToken) => Stream.FlushAsync(cancellationToken); }