Пример #1
0
 /// <summary>
 /// Registers a delegate that can create a warpper stream for
 /// compressing or uncompressing the data of a source stream.
 /// </summary>
 /// <param name="compressionMethod">Compression method being registered.</param>
 /// <param name="compressionMode">Indicates registration for ether
 /// compress or decompress mode.</param>
 /// <param name="creator">Delegate being registered.</param>
 /// <remarks>
 /// For compression, the delegate accepts a stream that writes to the archive
 /// and returns a wrapper stream that compresses bytes as they are written.
 /// For decompression, the delegate accepts a stream that reads from the archive
 /// and returns a wrapper stream that decompresses bytes as they are read.
 /// This wrapper stream model follows the design used by
 /// System.IO.Compression.DeflateStream, and indeed that class is used
 /// to implement the Deflate compression method by default.
 /// <para>To unregister a delegate, call this method again and pass
 /// null for the delegate parameter.</para>
 /// </remarks>
 /// <example>
 /// When the ZipEngine class is initialized, the Deflate compression method
 /// is automatically registered like this:
 /// <code>
 ///        ZipEngine.RegisterCompressionStreamCreator(
 ///            ZipCompressionMethod.Deflate,
 ///            CompressionMode.Compress,
 ///            delegate(Stream stream) {
 ///                return new DeflateStream(stream, CompressionMode.Compress, true);
 ///            });
 ///        ZipEngine.RegisterCompressionStreamCreator(
 ///            ZipCompressionMethod.Deflate,
 ///            CompressionMode.Decompress,
 ///            delegate(Stream stream) {
 ///                return new DeflateStream(stream, CompressionMode.Decompress, true);
 ///            });
 /// </code></example>
 public static void RegisterCompressionStreamCreator(
     ZipCompressionMethod compressionMethod,
     CompressionMode compressionMode,
     Converter <Stream, Stream> creator)
 {
     ZipEngine.InitCompressionStreamCreators();
     if (compressionMode == CompressionMode.Compress)
     {
         ZipEngine.compressionStreamCreators[compressionMethod] = creator;
     }
     else
     {
         ZipEngine.decompressionStreamCreators[compressionMethod] = creator;
     }
 }
Пример #2
0
 /// <summary>
 /// Creates a new instance of the zip engine.
 /// </summary>
 public ZipEngine()
     : base()
 {
     ZipEngine.InitCompressionStreamCreators();
 }