/// <inheritdoc /> public byte ReadByte() { var result = Stream.ReadByte(); if (result < 0) { EndOfStreamException.ThrowRead(); } return((byte)result); }
/// <inheritdoc /> public void ReadBytes(byte[] buffer, int offset, int count) { var totalBytesRead = 0; while (totalBytesRead < count) { var bytesRead = Stream.Read(buffer, totalBytesRead, count - totalBytesRead); if (bytesRead == 0) { EndOfStreamException.ThrowRead(); } totalBytesRead += bytesRead; } }
/// <inheritdoc /> public async Task ReadBytesAsync(byte[] buffer, int offset, int count) { var totalBytesRead = 0; while (totalBytesRead < count) { var bytesRead = await Stream.ReadAsync(buffer, totalBytesRead, count - totalBytesRead).ConfigureAwait(false); if (bytesRead == 0) { EndOfStreamException.ThrowRead(); } totalBytesRead += bytesRead; } }