internal EncoderStream(System.IO.Stream stream, ByteEncoder encoder, EncoderStreamAccess access, bool ownsStream) { if (stream == null) throw new System.ArgumentNullException(nameof(stream)); if (encoder == null) throw new System.ArgumentNullException(nameof(encoder)); if (access == EncoderStreamAccess.Read) { if (!stream.CanRead) throw new System.NotSupportedException(Resources.EncodersStrings.EncStrCannotRead); } else if (!stream.CanWrite) throw new System.NotSupportedException(Resources.EncodersStrings.EncStrCannotWrite); this.stream = stream; this.encoder = encoder; this.access = access; this.ownsStream = ownsStream; length = long.MaxValue; buffer = new byte[4096]; }
protected override void Dispose(bool disposing) { if (disposing && this.IsOpen) { if (this.CanWrite) this.FlushEncoder(true); if (stream != null) { stream.Dispose(); stream = null; } if (encoder != null) { encoder.Dispose(); encoder = null; } } base.Dispose(disposing); }