namespace StockSharp.Fix.Native; /// /// Data reader base class. /// /// /// Initialize . /// /// The stream from which data will be read. /// Text encoding. /// Whether to dispose the stream when this instance is disposed. public abstract class BaseFixReader(Stream stream, Encoding encoding, bool ownsStream = false) : FixBase(stream, encoding, ownsStream) { private readonly byte[] _buffer = new byte[1]; /// /// Get byte. /// /// Cancellation token. /// Byte. public async ValueTask ReadByteAsync(CancellationToken cancellationToken) { await Stream.ReadExactlyAsync(_buffer, 0, 1, cancellationToken).NoWait(); var b = _buffer[0]; CalcCheckSum(b); return b; } /// /// Read array value. /// /// Buffer. /// Cancellation token. public async ValueTask ReadBytesAsync(Memory buffer, CancellationToken cancellationToken) { await Stream.ReadExactlyAsync(buffer, cancellationToken).NoWait(); CalcCheckSum(buffer.Span); Dump(buffer.Span); } }