Example #1
0
        bool IReader.TryRead(out Block block)
        {
            if (sourceStream.Length > sourceStream.Position)
            {
                var buffer = new byte[GZipTools.GetSizeInfo(sourceStream)];
                sourceStream.Read(buffer, 0, buffer.Length);

                block = new Block(buffer, TotalBlockRead++);

                return(true);
            }

            block = null;
            return(false);
        }
Example #2
0
        Block IProcessor.Process(Block block)
        {
            Block processedBlock;

            using (var compressedDataStream = new MemoryStream())
            {
                using (var GZipStream = new GZipStream(compressedDataStream, CompressionMode.Compress))
                {
                    GZipStream.Write(block.Data, 0, block.Size);
                }

                processedBlock = new Block(GZipTools.AddSizeInfo(compressedDataStream.ToArray()), block.Number);
            }
            TotalBlockProcessed++;
            return(processedBlock);
        }