public override int Read(byte[] buffer, int offset, int count)
{
if (!BaseStream.CanRead)
{
throw new NotSupportedException();
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
if (count + offset > buffer.Length)
{
throw new ArgumentException("The sum of offset and count is larger than the buffer length");
}
if (_disposed)
{
throw new ObjectDisposedException("PushbackInputStream", "Cannot access a closed Stream.");
}
if (count == 0)
{
return 0;
}
if (_hasUnread)
{
buffer[offset] = _unreadByte;
_hasUnread = false;
return 1 + BaseStream.Read(buffer, offset + 1, count - 1);
}
return BaseStream.Read(buffer, offset, count);
}