コード例 #1
0
        /// <summary>
        /// Decodes length for collection types depending on the protocol version
        /// </summary>
        internal static int DecodeCollectionLength(ProtocolVersion protocolVersion, byte[] buffer, ref int index)
        {
            int result;

            if (!protocolVersion.Uses4BytesCollectionLength())
            {
                //length is a short
                result = BeConverter.ToInt16(buffer, index);
                index += 2;
            }
            else
            {
                //length is expressed in int
                result = BeConverter.ToInt32(buffer, index);
                index += 4;
            }
            return(result);
        }