internal TAs ReadObjectInternal <T, TAs>(Stream stream)
        {
            TAs tA;

            if (!stream.CanSeek)
            {
                throw new AmqpException(AmqpError.DecodeError, "stream.CanSeek must be true.");
            }
            SerializableType type             = this.GetType(typeof(T));
            ByteBuffer       byteBuffer       = null;
            long             position         = stream.Position;
            BufferListStream bufferListStream = stream as BufferListStream;

            if (bufferListStream == null)
            {
                byteBuffer = new ByteBuffer((int)stream.Length, false);
                int num = stream.Read(byteBuffer.Buffer, 0, byteBuffer.Capacity);
                byteBuffer.Append(num);
            }
            else
            {
                ArraySegment <byte> nums = bufferListStream.ReadBytes(2147483647);
                byteBuffer = new ByteBuffer(nums.Array, nums.Offset, nums.Count);
            }
            using (byteBuffer)
            {
                TAs tA1 = (TAs)type.ReadObject(byteBuffer);
                if (byteBuffer.Length > 0)
                {
                    stream.Position = position + (long)byteBuffer.Offset;
                }
                tA = tA1;
            }
            return(tA);
        }