/// <inheritdoc /> public async Task <byte[]> PeekBytesAsync(int count) { if (isPrendedBytesFinished) { return(await DecoratedReader.PeekBytesAsync(count) .ConfigureAwait(false)); } else { byte[] bytes = null; if (count <= PrependedBytes.Length - ByteCount) { bytes = PrependedBytes.Skip(ByteCount) .Take(count) .ToArray(); } else //We need to combine { bytes = PrependedBytes.Skip(ByteCount) .Concat(await DecoratedReader.PeekBytesAsync(count - (PrependedBytes.Length - ByteCount)).ConfigureAwait(false)) .ToArray(); } //Peeking so don't move the bytecount forward return(bytes); } }
/// <inheritdoc /> public async Task <byte[]> ReadBytesAsync(int count) { if (isPrendedBytesFinished) { return(await DecoratedReader.ReadBytesAsync(count) .ConfigureAwait(false)); } else { byte[] bytes = null; if (count <= PrependedBytes.Length - ByteCount) { bytes = PrependedBytes.Skip(ByteCount) .Take(count) .ToArray(); } else //We need to combine { bytes = PrependedBytes.Skip(ByteCount) .Concat(await DecoratedReader.ReadBytesAsync(count - (PrependedBytes.Length - ByteCount)).ConfigureAwait(false)) .ToArray(); } //Set the byte count as finished or forward as many as possible ByteCount = Math.Min(count + ByteCount, PrependedBytes.Length); return(bytes); } }
/// <inheritdoc /> public override byte[] ReadBytes(int count) { if (isPrendedBytesFinished) { return(DecoratedReader.ReadBytes(count)); } else { byte[] bytes = null; if (count <= PrependedBytes.Length - ByteCount) { bytes = PrependedBytes.Skip(ByteCount) .Take(count) .ToArray(); } else //We need to combine { bytes = PrependedBytes.Skip(ByteCount) .Concat(DecoratedReader.ReadBytes(count - (PrependedBytes.Length - ByteCount))) .ToArray(); } //Set the byte count as finished or forward as many as possible ByteCount = Math.Min(count + ByteCount, PrependedBytes.Length); return(bytes); } }
/// <inheritdoc /> public override byte[] PeekBytes(int count) { if (isPrendedBytesFinished) { return(DecoratedReader.PeekBytes(count)); } else { byte[] bytes = null; if (count <= PrependedBytes.Length - ByteCount) { bytes = PrependedBytes.Skip(ByteCount) .Take(count) .ToArray(); } else //We need to combine { bytes = PrependedBytes.Skip(ByteCount) .Concat(DecoratedReader.PeekBytes(count - (PrependedBytes.Length - ByteCount))) .ToArray(); } //Peeking so don't move the bytecount forward return(bytes); } }
/// <inheritdoc /> public override byte[] ReadAllBytes() { if (isPrendedBytesFinished) { return(DecoratedReader.ReadAllBytes()); } else { return(PrependedBytes.Skip(ByteCount) .Concat(DecoratedReader.ReadAllBytes()) .ToArray()); } }
/// <inheritdoc /> public async Task <byte[]> ReadAllBytesAsync() { if (isPrendedBytesFinished) { return(await DecoratedReader.ReadAllBytesAsync() .ConfigureAwait(false)); } else { return(PrependedBytes.Skip(ByteCount) .Concat(await DecoratedReader.ReadAllBytesAsync().ConfigureAwait(false)) .ToArray()); } }