//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ /// <summary> /// Constructor /// </summary> /// <param name="baseStream">part stream - not closed - caller determines lifetime</param> /// <param name="position">current logical stream position</param> /// <param name="tempStream">should be an IsolatedStorageFileStream - not closed - caller determines lifetime</param> /// <param name="transformer">class that does the compression/decompression</param> /// <remarks>This class should only invoked when emulation is required. /// Does not close any given stream, even when Close is called. This means that it requires /// another wrapper Stream class.</remarks> internal CompressEmulationStream(Stream baseStream, Stream tempStream, long position, IDeflateTransform transformer) { if (position < 0) { throw new ArgumentOutOfRangeException("position"); } if (baseStream == null) { throw new ArgumentNullException("baseStream"); } // seek and read required for emulation if (!baseStream.CanSeek) { throw new InvalidOperationException(SR.SeekNotSupported); } if (!baseStream.CanRead) { throw new InvalidOperationException(SR.ReadNotSupported); } if (tempStream == null) { throw new ArgumentNullException("tempStream"); } if (transformer == null) { throw new ArgumentNullException("transformer"); } _baseStream = baseStream; _tempStream = tempStream; _transformer = transformer; // extract to temporary stream _baseStream.Position = 0; _tempStream.Position = 0; _transformer.Decompress(baseStream, tempStream); // seek to the current logical position _tempStream.Position = position; }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ /// <summary> /// Constructor /// </summary> /// <param name="baseStream">part stream - not closed - caller determines lifetime</param> /// <param name="position">current logical stream position</param> /// <param name="tempStream">should be an IsolatedStorageFileStream - not closed - caller determines lifetime</param> /// <param name="transformer">class that does the compression/decompression</param> /// <remarks>This class should only invoked when emulation is required. /// Does not close any given stream, even when Close is called. This means that it requires /// another wrapper Stream class.</remarks> internal CompressEmulationStream(Stream baseStream, Stream tempStream, long position, IDeflateTransform transformer) { if (position < 0) throw new ArgumentOutOfRangeException("position"); if (baseStream == null) throw new ArgumentNullException("baseStream"); // seek and read required for emulation if (!baseStream.CanSeek) throw new InvalidOperationException(SR.Get(SRID.SeekNotSupported)); if (!baseStream.CanRead) throw new InvalidOperationException(SR.Get(SRID.ReadNotSupported)); if (tempStream == null) throw new ArgumentNullException("tempStream"); if (transformer == null) throw new ArgumentNullException("transformer"); _baseStream = baseStream; _tempStream = tempStream; _transformer = transformer; // extract to temporary stream _baseStream.Position = 0; _tempStream.Position = 0; _transformer.Decompress(baseStream, tempStream); // seek to the current logical position _tempStream.Position = position; }