Skip to content

Commit

Permalink
Improve wrapper stream
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Jan 8, 2023
1 parent fcb0e2c commit f103729
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static void ThrowExceededBufferLimit(int limit)
}

public override bool CanRead => _innerStream.CanRead;
public override bool CanSeek => false;
public override bool CanSeek => _innerStream.CanSeek;
public override bool CanWrite => false;

#if NETCOREAPP
Expand Down Expand Up @@ -75,12 +75,20 @@ public override async Task<int> ReadAsync(byte[] buffer, int offset, int count,
}
#endif

public override void Flush() => throw new InvalidOperationException();
public override int Read(byte[] buffer, int offset, int count) => throw new InvalidOperationException();
public override long Seek(long offset, SeekOrigin origin) => throw new InvalidOperationException();
public override void SetLength(long value) => throw new InvalidOperationException();
public override void Write(byte[] buffer, int offset, int count) => throw new InvalidOperationException();
public override long Length => throw new InvalidOperationException();
public override long Position { get => throw new InvalidOperationException(); set => throw new InvalidOperationException(); }
public override int Read(byte[] buffer, int offset, int count)
{
int read = _innerStream.Read(buffer, offset, count);
CheckLengthLimit(read);
return read;
}

public override void Flush() => _innerStream.Flush();
public override Task FlushAsync(CancellationToken cancellationToken) => _innerStream.FlushAsync(cancellationToken);
public override long Seek(long offset, SeekOrigin origin) => _innerStream.Seek(offset, origin);
public override void SetLength(long value) => _innerStream.SetLength(value);
public override long Length => _innerStream.Length;
public override long Position { get => _innerStream.Position; set => _innerStream.Position = value; }

public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
}
}

0 comments on commit f103729

Please sign in to comment.