public Stream Clone() { this.AssertOpen(); if (EncoderStreamAccess.Write == this.access) { throw new NotSupportedException(EncodersStrings.EncStrCannotCloneWriteableStream); } ICloneableStream cloneableStream = this.stream as ICloneableStream; if (cloneableStream == null && this.stream.CanSeek) { this.stream = new AutoPositionReadOnlyStream(this.stream, this.ownsStream); this.ownsStream = true; cloneableStream = (this.stream as ICloneableStream); } if (cloneableStream != null) { EncoderStream encoderStream = base.MemberwiseClone() as EncoderStream; encoderStream.buffer = (this.buffer.Clone() as byte[]); encoderStream.stream = cloneableStream.Clone(); encoderStream.encoder = this.encoder.Clone(); return(encoderStream); } throw new NotSupportedException(EncodersStrings.EncStrCannotCloneChildStream(this.stream.GetType().ToString())); }
public void Convert(Stream sourceStream, Stream destinationStream) { if (sourceStream == null) { throw new ArgumentNullException("sourceStream"); } Stream stream = new EncoderStream(destinationStream, this, EncoderStreamAccess.Write); byte[] array = new byte[4096]; for (;;) { int num = sourceStream.Read(array, 0, array.Length); if (num == 0) { break; } stream.Write(array, 0, num); } stream.Flush(); }