Parse() public static method

Parse the AddressBookPropertyValueList structure.
public static Parse ( byte rawData, int &index ) : AddressBookPropertyValueList
rawData byte The raw data of response buffer.
index int The start index.
return AddressBookPropertyValueList
Ejemplo n.º 1
0
        /// <summary>
        /// Parse the GetProps request type response body.
        /// </summary>
        /// <param name="rawData">The raw data of response.</param>
        /// <returns>The GetProps request type response body.</returns>
        public static GetPropsResponseBody Parse(byte[] rawData)
        {
            GetPropsResponseBody responseBody = new GetPropsResponseBody();
            int index = 0;

            responseBody.StatusCode = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            responseBody.CodePage = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            responseBody.HasPropertyValues = BitConverter.ToBoolean(rawData, index);
            index += sizeof(bool);
            if (responseBody.HasPropertyValues)
            {
                responseBody.PropertyValues = AddressBookPropertyValueList.Parse(rawData, ref index);
            }
            else
            {
                responseBody.PropertyValues = null;
            }

            responseBody.AuxiliaryBufferSize = BitConverter.ToUInt32(rawData, index);
            index += 4;
            responseBody.AuxiliaryBuffer = new byte[responseBody.AuxiliaryBufferSize];
            Array.Copy(rawData, index, responseBody.AuxiliaryBuffer, 0, responseBody.AuxiliaryBufferSize);
            return(responseBody);
        }
        /// <summary>
        /// Parse the GetSpecialTable request type response body.
        /// </summary>
        /// <param name="rawData">The raw data of response.</param>
        /// <returns>The GetSpecialTable request type response body.</returns>
        public static GetSpecialTableResponseBody Parse(byte[] rawData)
        {
            GetSpecialTableResponseBody responseBody = new GetSpecialTableResponseBody();
            int index = 0;

            responseBody.StatusCode = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            responseBody.CodePage = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            responseBody.HasVersion = BitConverter.ToBoolean(rawData, index);
            index += sizeof(bool);
            if (responseBody.HasVersion)
            {
                responseBody.Version = BitConverter.ToUInt32(rawData, index);
                index += sizeof(uint);
            }
            else
            {
                responseBody.Version = null;
            }

            responseBody.HasRows = BitConverter.ToBoolean(rawData, index);
            index += sizeof(bool);
            if (responseBody.HasRows)
            {
                responseBody.RowCount = BitConverter.ToUInt32(rawData, index);
                index            += sizeof(uint);
                responseBody.Rows = new AddressBookPropertyValueList[(uint)responseBody.RowCount];
                for (int i = 0; i < responseBody.RowCount; i++)
                {
                    responseBody.Rows[i] = AddressBookPropertyValueList.Parse(rawData, ref index);
                }
            }
            else
            {
                responseBody.RowCount = null;
                responseBody.Rows     = null;
            }

            responseBody.AuxiliaryBufferSize = BitConverter.ToUInt32(rawData, index);
            index += 4;
            responseBody.AuxiliaryBuffer = new byte[responseBody.AuxiliaryBufferSize];
            Array.Copy(rawData, index, responseBody.AuxiliaryBuffer, 0, responseBody.AuxiliaryBufferSize);
            return(responseBody);
        }