protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                if (null != this.firstStream)
                {
                    this.firstStream.Dispose();
                    this.firstStream = null;
                }

                if (null != this.secondStream)
                {
                    this.secondStream.Dispose();
                    this.secondStream = null;
                }

                if (!this.ReserveBuffer)
                {
                    if (null != this.firstBuffer)
                    {
                        this.memoryManager.ReleaseBuffers(this.firstBuffer.MemoryBuffer);
                        this.firstBuffer = null;
                    }

                    if (null != this.secondBuffer)
                    {
                        this.memoryManager.ReleaseBuffers(this.secondBuffer.MemoryBuffer);
                        this.secondBuffer = null;
                    }
                }
            }
        }
        public TransferDownloadStream(
            MemoryManager memoryManager,
            TransferDownloadBuffer firstBuffer,
            int firstOffset,
            int firstCount,
            TransferDownloadBuffer secondBuffer,
            int secondOffset,
            int secondCount)
        {
            this.memoryManager = memoryManager;
            this.firstBuffer   = firstBuffer;
            this.firstOffset   = firstOffset;

            if (firstBuffer.MemoryBuffer.Length == 1)
            {
                this.firstStream = new MemoryStream(this.firstBuffer.MemoryBuffer[0], firstOffset, firstCount);
            }
            else
            {
                this.firstStream = new ChunkedMemoryStream(this.firstBuffer.MemoryBuffer, firstOffset, firstCount);
            }

            if (null != secondBuffer)
            {
                this.secondBuffer = secondBuffer;
                this.secondOffset = secondOffset;

                if (secondBuffer.MemoryBuffer.Length == 1)
                {
                    this.secondStream = new MemoryStream(this.secondBuffer.MemoryBuffer[0], secondOffset, secondCount);
                }
                else
                {
                    this.secondStream = new ChunkedMemoryStream(this.secondBuffer.MemoryBuffer, secondOffset, secondCount);
                }
            }
        }
 public TransferDownloadStream(MemoryManager memoryManager, TransferDownloadBuffer buffer, int offset, int count)
     : this(memoryManager, buffer, offset, count, null, 0, 0)
 {
 }