C# 클래스 Ionic.Zlib.ZlibStream

상속: System.IO.Stream
파일 보기 프로젝트 열기: haf/DotNetZip.Semverd 1 사용 예제들

공개 메소드들

메소드 설명
CompressBuffer ( byte b ) : byte[]

Compress a byte array into a new byte array using ZLIB.

Uncompress it with ZlibStream.UncompressBuffer(byte[]).

CompressString ( String s ) : byte[]

Compress a string into a byte array using ZLIB.

Uncompress it with ZlibStream.UncompressString(byte[]).

Flush ( ) : void

Flush the stream.

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

Read data from the stream.

If you wish to use the ZlibStream to compress data while reading, you can create a ZlibStream with CompressionMode.Compress, providing an uncompressed data stream. Then call Read() on that ZlibStream, and the data read will be compressed. If you wish to use the ZlibStream to decompress data while reading, you can create a ZlibStream with CompressionMode.Decompress, providing a readable compressed data stream. Then call Read() on that ZlibStream, and the data will be decompressed as it is read.

A ZlibStream can be used for Read() or Write(), but not both.

Seek ( long offset, System origin ) : long

Calling this method always throws a NotSupportedException.

SetLength ( long value ) : void

Calling this method always throws a NotSupportedException.

UncompressBuffer ( byte compressed ) : byte[]

Uncompress a ZLIB-compressed byte array into a byte array.

UncompressString ( byte compressed ) : String

Uncompress a ZLIB-compressed byte array into a single string.

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

Write data to the stream.

If you wish to use the ZlibStream to compress data while writing, you can create a ZlibStream with CompressionMode.Compress, and a writable output stream. Then call Write() on that ZlibStream, providing uncompressed data as input. The data sent to the output stream will be the compressed form of the data written. If you wish to use the ZlibStream to decompress data while writing, you can create a ZlibStream with CompressionMode.Decompress, and a writable output stream. Then call Write() on that stream, providing previously compressed data. The data sent to the output stream will be the decompressed form of the data written.

A ZlibStream can be used for Read() or Write(), but not both.

ZlibStream ( System stream, CompressionMode mode ) : System

Create a ZlibStream using the specified CompressionMode.

When mode is CompressionMode.Compress, the ZlibStream will use the default compression level. The "captive" stream will be closed when the ZlibStream is closed.

ZlibStream ( System stream, CompressionMode mode, CompressionLevel level ) : System

Create a ZlibStream using the specified CompressionMode and the specified CompressionLevel.

When mode is CompressionMode.Decompress, the level parameter is ignored. The "captive" stream will be closed when the ZlibStream is closed.

ZlibStream ( System stream, CompressionMode mode, CompressionLevel level, bool leaveOpen ) : System

Create a ZlibStream 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 System.IO.MemoryStream that will be re-read after compression. Specify true for the parameter to leave the stream open.

When mode is CompressionMode.Decompress, the level parameter is ignored.

ZlibStream ( System stream, CompressionMode mode, bool leaveOpen ) : System

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

When mode is CompressionMode.Compress, the ZlibStream will use the default compression level.

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 System.IO.MemoryStream that will be re-read after compression. Specify true for the leaveOpen parameter to leave the stream open.

See the other overloads of this constructor for example code.

보호된 메소드들

메소드 설명
Dispose ( bool disposing ) : void

Dispose the stream.

This may or may not result in a Close() call on the captive stream. See the constructors that have a leaveOpen parameter for more information.

This method may be invoked in two distinct scenarios. If disposing == true, the method has been called directly or indirectly by a user's code, for example via the public Dispose() method. In this case, both managed and unmanaged resources can be referenced and disposed. If disposing == false, the method has been called by the runtime from inside the object finalizer and this method should not reference other objects; in that case only unmanaged resources must be referenced or disposed.

메소드 상세

CompressBuffer() 공개 정적인 메소드

Compress a byte array into a new byte array using ZLIB.
Uncompress it with ZlibStream.UncompressBuffer(byte[]).
public static CompressBuffer ( byte b ) : byte[]
b byte /// A buffer to compress. ///
리턴 byte[]

CompressString() 공개 정적인 메소드

Compress a string into a byte array using ZLIB.
Uncompress it with ZlibStream.UncompressString(byte[]).
public static CompressString ( String s ) : byte[]
s String /// A string to compress. The string will first be encoded /// using UTF8, then compressed. ///
리턴 byte[]

Dispose() 보호된 메소드

Dispose the stream.

This may or may not result in a Close() call on the captive stream. See the constructors that have a leaveOpen parameter for more information.

This method may be invoked in two distinct scenarios. If disposing == true, the method has been called directly or indirectly by a user's code, for example via the public Dispose() method. In this case, both managed and unmanaged resources can be referenced and disposed. If disposing == false, the method has been called by the runtime from inside the object finalizer and this method should not reference other objects; in that case only unmanaged resources must be referenced or disposed.

protected Dispose ( bool disposing ) : void
disposing bool /// indicates whether the Dispose method was invoked by user code. ///
리턴 void

Flush() 공개 메소드

Flush the stream.
public Flush ( ) : void
리턴 void

Read() 공개 메소드

Read data from the stream.

If you wish to use the ZlibStream to compress data while reading, you can create a ZlibStream with CompressionMode.Compress, providing an uncompressed data stream. Then call Read() on that ZlibStream, and the data read will be compressed. If you wish to use the ZlibStream to decompress data while reading, you can create a ZlibStream with CompressionMode.Decompress, providing a readable compressed data stream. Then call Read() on that ZlibStream, and the data will be decompressed as it is read.

A ZlibStream can be used for Read() or Write(), but not both.

public Read ( byte buffer, int offset, int count ) : int
buffer byte /// The buffer into which the read 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 NotSupportedException.
public Seek ( long offset, System origin ) : long
offset long /// The offset to seek to.... /// IF THIS METHOD ACTUALLY DID ANYTHING. ///
origin System /// The reference specifying how to apply the offset.... IF /// THIS METHOD ACTUALLY DID ANYTHING. ///
리턴 long

SetLength() 공개 메소드

Calling this method always throws a NotSupportedException.
public SetLength ( long value ) : void
value long /// The new value for the stream length.... IF /// THIS METHOD ACTUALLY DID ANYTHING. ///
리턴 void

UncompressBuffer() 공개 정적인 메소드

Uncompress a ZLIB-compressed byte array into a byte array.
public static UncompressBuffer ( byte compressed ) : byte[]
compressed byte /// A buffer containing ZLIB-compressed data. ///
리턴 byte[]

UncompressString() 공개 정적인 메소드

Uncompress a ZLIB-compressed byte array into a single string.
public static UncompressString ( byte compressed ) : String
compressed byte /// A buffer containing ZLIB-compressed data. ///
리턴 String

Write() 공개 메소드

Write data to the stream.

If you wish to use the ZlibStream to compress data while writing, you can create a ZlibStream with CompressionMode.Compress, and a writable output stream. Then call Write() on that ZlibStream, providing uncompressed data as input. The data sent to the output stream will be the compressed form of the data written. If you wish to use the ZlibStream to decompress data while writing, you can create a ZlibStream with CompressionMode.Decompress, and a writable output stream. Then call Write() on that stream, providing previously compressed data. The data sent to the output stream will be the decompressed form of the data written.

A ZlibStream can be used for Read() or Write(), but not both.

public Write ( byte buffer, int offset, int count ) : void
buffer byte The buffer holding data to write to the stream.
offset int the offset within that data array to find the first byte to write.
count int the number of bytes to write.
리턴 void

ZlibStream() 공개 메소드

Create a ZlibStream using the specified CompressionMode.

When mode is CompressionMode.Compress, the ZlibStream will use the default compression level. The "captive" stream will be closed when the ZlibStream is closed.

public ZlibStream ( System stream, CompressionMode mode ) : System
stream System The stream which will be read or written.
mode CompressionMode Indicates whether the ZlibStream will compress or decompress.
리턴 System

ZlibStream() 공개 메소드

Create a ZlibStream using the specified CompressionMode and the specified CompressionLevel.

When mode is CompressionMode.Decompress, the level parameter is ignored. The "captive" stream will be closed when the ZlibStream is closed.

public ZlibStream ( System stream, CompressionMode mode, CompressionLevel level ) : System
stream System The stream to be read or written while deflating or inflating.
mode CompressionMode Indicates whether the ZlibStream will compress or decompress.
level CompressionLevel A tuning knob to trade speed for effectiveness.
리턴 System

ZlibStream() 공개 메소드

Create a ZlibStream 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 System.IO.MemoryStream that will be re-read after compression. Specify true for the parameter to leave the stream open.

When mode is CompressionMode.Decompress, the level parameter is ignored.

public ZlibStream ( System stream, CompressionMode mode, CompressionLevel level, bool leaveOpen ) : System
stream System The stream which will be read or written.
mode CompressionMode Indicates whether the ZlibStream will compress or decompress.
level CompressionLevel /// A tuning knob to trade speed for effectiveness. This parameter is /// effective only when mode is CompressionMode.Compress. ///
leaveOpen bool /// true if the application would like the stream to remain open after /// inflation/deflation. ///
리턴 System

ZlibStream() 공개 메소드

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

When mode is CompressionMode.Compress, the ZlibStream will use the default compression level.

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 System.IO.MemoryStream that will be re-read after compression. Specify true for the leaveOpen parameter to leave the stream open.

See the other overloads of this constructor for example code.

public ZlibStream ( System stream, CompressionMode mode, bool leaveOpen ) : System
stream System The stream which will be read or written. This is called the /// "captive" stream in other places in this documentation.
mode CompressionMode Indicates whether the ZlibStream will compress or decompress.
leaveOpen bool true if the application would like the stream to remain /// open after inflation/deflation.
리턴 System