Microsoft.Azure.Amqp.BufferListStream.ReadBuffers C# (CSharp) 메소드

ReadBuffers() 공개 메소드

public ReadBuffers ( int count, bool advance, bool &more ) : ArraySegment[]
count int
advance bool
more bool
리턴 ArraySegment[]
        public ArraySegment<byte>[] ReadBuffers(int count, bool advance, out bool more)
        {
            this.ThrowIfDisposed();
            more = false;
            if (this.readArray == this.bufferList.Count)
            {
                return null;
            }

            List<ArraySegment<byte>> buffers = new List<ArraySegment<byte>>();
            int readArrayCopy = this.readArray;
            int readOffsetCopy = this.readOffset;
            long positionCopy = this.position;
            while (count > 0 && this.readArray < this.bufferList.Count)
            {
                ArraySegment<byte> segment = this.bufferList[this.readArray];
                int bytesRemaining = segment.Count - this.readOffset;
                int bytesToCopy = Math.Min(bytesRemaining, count);
                buffers.Add(new ArraySegment<byte>(segment.Array, segment.Offset + this.readOffset, bytesToCopy));
                this.Advance(bytesToCopy, segment.Count);
                count -= bytesToCopy;
            }

            more = this.readArray < this.bufferList.Count;

            if (!advance)
            {
                this.readArray = readArrayCopy;
                this.readOffset = readOffsetCopy;
                this.position = positionCopy;
            }

            return buffers.ToArray();
        }