C# Класс RestSharp.Compression.ZLib.GZipStream

A class for compressing and decompressing GZIP streams.

The GZipStream is a Decorator on a . It adds GZIP compression or decompression to any stream.

Like the Compression.GZipStream in the .NET Base Class Library, the Ionic.Zlib.GZipStream can compress while writing, or decompress while reading, but not vice versa. The compression method used is GZIP, which is documented in IETF RFC 1952, "GZIP file format specification version 4.3".

A GZipStream can be used to decompress data (through Read()) or to compress data (through Write()), but not both.

If you wish to use the GZipStream to compress data, you must wrap it around a write-able stream. As you call Write() on the GZipStream, the data will be compressed into the GZIP format. If you want to decompress data, you must wrap the GZipStream around a readable stream that contains an IETF RFC 1952-compliant stream. The data will be decompressed as you call Read() on the GZipStream.

Though the GZIP format allows data from multiple files to be concatenated together, this stream handles only a single segment of GZIP format, typically representing a single file.

This class is similar to ZlibStream and DeflateStream. ZlibStream handles RFC1950-compliant streams. DeflateStream handles RFC1951-compliant streams. This class handles RFC1952-compliant streams.

Наследование: Stream
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Flush ( ) : void

Flush the stream.

GZipStream ( Stream stream ) : System

Create a GZipStream using the specified CompressionMode and the specified CompressionLevel, and explicitly specify whether the stream should be left open after Deflation or Inflation.

This constructor allows the application to request that the captive stream remain open after the deflation or inflation occurs. By default, after Close() is called on the stream, the captive stream is also closed. In some cases this is not desired, for example if the stream is a memory stream that will be re-read after compressed data has been written to it. Specify true for the leaveOpen parameter to leave the stream open.

As noted in the class documentation, the CompressionMode (Compress or Decompress) also establishes the "direction" of the stream. A GZipStream with CompressionMode.Compress works only through Write(). A GZipStream with CompressionMode.Decompress works only through Read().

Read ( byte buffer, int offset, int count ) : int

Read and decompress data from the source stream.

With a GZipStream, decompression is done through reading.

Seek ( long offset, SeekOrigin origin ) : long

Calling this method always throws a NotImplementedException.

SetLength ( long value ) : void

Calling this method always throws a NotImplementedException.

Write ( byte buffer, int offset, int count ) : void

Защищенные методы

Метод Описание
Dispose ( bool disposing ) : void

Dispose the stream.

This may or may not result in a Close() call on the captive stream. See the ctor's with leaveOpen parameters for more information.

Описание методов

Dispose() защищенный Метод

Dispose the stream.
This may or may not result in a Close() call on the captive stream. See the ctor's with leaveOpen parameters for more information.
protected Dispose ( bool disposing ) : void
disposing bool
Результат void

Flush() публичный Метод

Flush the stream.
public Flush ( ) : void
Результат void

GZipStream() публичный Метод

Create a GZipStream using the specified CompressionMode and the specified CompressionLevel, and explicitly specify whether the stream should be left open after Deflation or Inflation.

This constructor allows the application to request that the captive stream remain open after the deflation or inflation occurs. By default, after Close() is called on the stream, the captive stream is also closed. In some cases this is not desired, for example if the stream is a memory stream that will be re-read after compressed data has been written to it. Specify true for the leaveOpen parameter to leave the stream open.

As noted in the class documentation, the CompressionMode (Compress or Decompress) also establishes the "direction" of the stream. A GZipStream with CompressionMode.Compress works only through Write(). A GZipStream with CompressionMode.Decompress works only through Read().

public GZipStream ( Stream stream ) : System
stream Stream The stream which will be read or written.
Результат System

Read() публичный Метод

Read and decompress data from the source stream.
With a GZipStream, decompression is done through reading.
public Read ( byte buffer, int offset, int count ) : int
buffer byte The buffer into which the decompressed data should be placed.
offset int the offset within that data array to put the first byte read.
count int the number of bytes to read.
Результат int

Seek() публичный Метод

Calling this method always throws a NotImplementedException.
public Seek ( long offset, SeekOrigin origin ) : long
offset long irrelevant; it will always throw!
origin SeekOrigin irrelevant; it will always throw!
Результат long

SetLength() публичный Метод

Calling this method always throws a NotImplementedException.
public SetLength ( long value ) : void
value long irrelevant; this method will always throw!
Результат void

Write() публичный Метод

public Write ( byte buffer, int offset, int count ) : void
buffer byte
offset int
count int
Результат void