Skip to content

Instantly share code, notes, and snippets.

@droyad
Created March 12, 2019 22:58
Show Gist options
  • Save droyad/088ca4e2991b2678085500535d628747 to your computer and use it in GitHub Desktop.
Save droyad/088ca4e2991b2678085500535d628747 to your computer and use it in GitHub Desktop.
Stream wrapper to work around https://github.com/dotnet/corefx/issues/27326
/// <summary>
/// Work around for https://github.com/dotnet/corefx/issues/27326
/// </summary>
public class NonFlushingStream : Stream
{
private readonly Stream _stream;
public NonFlushingStream(Stream stream)
{
_stream = stream;
}
public override void Flush()
{
}
public override int Read(byte[] buffer, int offset, int count) => _stream.Read(buffer, offset, count);
public override long Seek(long offset, SeekOrigin origin) => _stream.Seek(offset, origin);
public override void SetLength(long value) => _stream.SetLength(value);
public override void Write(byte[] buffer, int offset, int count) => _stream.Write(buffer, offset, count);
public override bool CanRead => _stream.CanRead;
public override bool CanSeek => _stream.CanSeek;
public override bool CanWrite => _stream.CanWrite;
public override long Length => _stream.Length;
public override long Position
{
get => _stream.Position;
set => _stream.Position = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment