Example #1
0
        /// <summary>
        /// Parse the GetTemplateInfo request type response body.
        /// </summary>
        /// <param name="rawData">The raw data of response.</param>
        /// <returns>The GetTemplateInfo request type response body.</returns>
        public static GetTemplateInfoResponseBody Parse(byte[] rawData)
        {
            GetTemplateInfoResponseBody responseBody = new GetTemplateInfoResponseBody();
            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.HasRow = BitConverter.ToBoolean(rawData, index);
            index += sizeof(bool);
            if (responseBody.HasRow)
            {
                responseBody.Row = AddressBookPropValueList.Parse(rawData, ref index);
            }
            else
            {
                responseBody.Row = 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>
        /// Compare whether two AddressBookPropValueLists are equal.
        /// </summary>
        /// <param name="addressBookPropValueList1">The first AddressBookPropValueList used to compare.</param>
        /// <param name="addressBookPropValueList2">The second AddressBookPropValueList used to compare.</param>
        /// <returns>Returns true if they are equal; otherwise false.</returns>
        public static bool AreTwoAddressBookPropValueListEqual(AddressBookPropValueList addressBookPropValueList1, AddressBookPropValueList addressBookPropValueList2)
        {
            if (addressBookPropValueList1.PropertyValueCount != addressBookPropValueList2.PropertyValueCount)
            {
                site.Log.Add(
                    LogEntryKind.Debug,
                    "The length the two AddressBookPropValueList are not equal. The length of addressBookPropValueList1 is {0}, the length of addressBookPropValueList2 is {1}.",
                    addressBookPropValueList1.PropertyValueCount,
                    addressBookPropValueList2.PropertyValueCount);

                return(false);
            }
            else
            {
                TaggedPropertyValue[] propertyValues1 = addressBookPropValueList1.PropertyValues;
                TaggedPropertyValue[] propertyValues2 = addressBookPropValueList2.PropertyValues;

                for (int i = 0; i < propertyValues1.Length; i++)
                {
                    PropertyTag propertyTag1 = propertyValues1[i].PropertyTag;
                    PropertyTag propertyTag2 = propertyValues2[i].PropertyTag;

                    if (propertyTag1.PropertyId != propertyTag2.PropertyId)
                    {
                        site.Log.Add(
                            LogEntryKind.Debug,
                            "The property ID of property {0} in the two property tag array are not equal. The property ID of propertyTag1 is {1}, the property ID of propertyTag2 is {2}",
                            i,
                            propertyTag1.PropertyId,
                            propertyTag2.PropertyId);

                        return(false);
                    }
                    else if (propertyTag1.PropertyType != propertyTag2.PropertyType)
                    {
                        site.Log.Add(
                            LogEntryKind.Debug,
                            "The property type of property {0} in the two property tag array are not equal. The property type of propertyTag1 is {1}, the property type of propertyTag2 is {2}",
                            i,
                            propertyTag1.PropertyType,
                            propertyTag2.PropertyType);

                        return(false);
                    }
                }
            }

            return(true);
        }
        /// <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 AddressBookPropValueList[(uint)responseBody.RowCount];
                for (int i = 0; i < responseBody.RowCount; i++)
                {
                    responseBody.Rows[i] = AddressBookPropValueList.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);
        }
Example #4
0
        /// <summary>
        /// Parse the AddressBookPropValueList structure.
        /// </summary>
        /// <param name="rawData">The raw data of response buffer.</param>
        /// <param name="index">The start index.</param>
        /// <returns>Instance of the AddressBookPropValueList.</returns>
        public static AddressBookPropValueList Parse(byte[] rawData, ref int index)
        {
            AddressBookPropValueList addressBookPropValueList = new AddressBookPropValueList();

            addressBookPropValueList.PropertyValueCount = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            Context.Instance.PropertyBytes = rawData;
            Context.Instance.CurIndex      = index;
            Context.Instance.CurProperty   = new Property(PropertyType.PtypUnspecified);

            addressBookPropValueList.PropertyValues = new TaggedPropertyValue[addressBookPropValueList.PropertyValueCount];
            for (int i = 0; i < addressBookPropValueList.PropertyValueCount; i++)
            {
                // Parse the TaggedPropertyValue from the response buffer.
                TaggedPropertyValue taggedPropertyValue = new TaggedPropertyValue();
                taggedPropertyValue.Parse(Context.Instance);
                addressBookPropValueList.PropertyValues[i] = taggedPropertyValue;
            }

            index = Context.Instance.CurIndex;

            return(addressBookPropValueList);
        }