Пример #1
0
        /// <summary>
        /// Decompresses the specified source stream.
        /// </summary>
        /// <param name="sourceStream">The source stream.</param>
        /// <param name="nodeId"></param>
        /// <returns>Decompressed stream</returns>
        public Stream Decompress(Stream sourceStream, string nodeId)
        {
            var args = new StreamEventArgs(sourceStream, nodeId);

            // try custom decompression
            Owner.DoBeforeDecompress(args);
            // if no custom decompression then do default
            if (!args.Done)
            {
                using (var zipStream = new GZipStream(sourceStream, CompressionMode.Decompress, false))
                {
                    zipStream.CopyTo(args.DestStream);
                }
            }
            args.DestStream.Seek(0, SeekOrigin.Begin);
            Owner.DoAfterDecompress(args);
            return(args.DestStream);
        }
Пример #2
0
 /// <summary>
 /// Decompresses the specified source stream.
 /// </summary>
 /// <param name="sourceStream">The source stream.</param>
 /// <param name="nodeId"></param>
 /// <returns>Decompressed stream</returns>
 public Stream Decompress(Stream sourceStream, string nodeId)
 {
     var args = new StreamEventArgs(sourceStream, nodeId);
     // try custom decompression
     Owner.DoBeforeDecompress(args);
     // if no custom decompression then do default
     if (!args.Done)
     {
         using (var zipStream = new GZipStream(sourceStream, CompressionMode.Decompress, false))
         {
             zipStream.CopyTo(args.DestStream);
         }
     }
     args.DestStream.Seek(0, SeekOrigin.Begin);
     Owner.DoAfterDecompress(args);
     return args.DestStream;
 }
Пример #3
0
 internal void DoBeforeDecompress(StreamEventArgs e)
 {
     var handler = BeforeDecompress;
     if (handler != null) handler(this, e);
 }
Пример #4
0
 internal void DoAfterCompress(StreamEventArgs e)
 {
     var handler = AfterCompress;
     if (handler != null) handler(this, e);
 }