Пример #1
0
        protected override void FinalizeWrite()
        {
            Position = HeaderSize;
            BufferSegment segment = BufferManager.GetSegment(ContentLength);
            int           deflatedLength;

            Compression.CompressZLib((backingStream.BaseStream as MemoryStream).GetBuffer(), segment.Buffer.Array,
                                     7, out deflatedLength);
            Write(deflatedLength);
            Write(segment.Buffer.Array);
            segment.DecrementUsage();
            base.FinalizeWrite();
        }
Пример #2
0
        protected override void FinalizeWrite()
        {
            // Set us at the payload start
            Position = HeaderSize;

            int deflatedLength;

            var segment = BufferManager.GetSegment(ContentLength);

            var backingBuf = (backingStream.BaseStream as MemoryStream).GetBuffer(); // backingStream can only be a MemoryStream

            Compression.CompressZLib(backingBuf, segment.Buffer.Array, 7, out deflatedLength);
            Write(deflatedLength);
            Write(segment.Buffer.Array);

            segment.DecrementUsage();// should check in the buffer

            base.FinalizeWrite();
        }