The AddressBookPropertyRow structure contains a list of property values without including the property tags that correspond to the property values.
コード例 #1
0
        /// <summary>
        /// Parse the response data into response body.
        /// </summary>
        /// <param name="rawData">The raw data of response</param>
        /// <returns>The response body of the request</returns>
        public static ResolveNamesResponseBody Parse(byte[] rawData)
        {
            ResolveNamesResponseBody responseBody = new ResolveNamesResponseBody();
            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.HasMinimalIds = BitConverter.ToBoolean(rawData, index);
            index += sizeof(bool);
            if (responseBody.HasMinimalIds)
            {
                responseBody.MinimalIdCount = BitConverter.ToUInt32(rawData, index);
                index += sizeof(uint);
                responseBody.MinimalIds = new uint[(uint)responseBody.MinimalIdCount];
                for (int i = 0; i < responseBody.MinimalIdCount; i++)
                {
                    responseBody.MinimalIds[i] = BitConverter.ToUInt32(rawData, index);
                    index += sizeof(uint);
                }
            }
            else
            {
                responseBody.MinimalIdCount = null;
                responseBody.MinimalIds     = null;
            }

            responseBody.HasRowsAndPropertyTags = BitConverter.ToBoolean(rawData, index);
            index += sizeof(bool);
            if (responseBody.HasRowsAndPropertyTags)
            {
                responseBody.PropertyTags = LargePropTagArray.Parse(rawData, ref index);
                responseBody.RowCount     = BitConverter.ToUInt32(rawData, index);
                index += sizeof(uint);
                responseBody.RowData = new AddressBookPropertyRow[(uint)responseBody.RowCount];
                for (int i = 0; i < responseBody.RowCount; i++)
                {
                    responseBody.RowData[i] = AddressBookPropertyRow.Parse(rawData, (LargePropTagArray)responseBody.PropertyTags, ref index);
                }
            }

            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);
        }
コード例 #2
0
        /// <summary>
        /// Parse the response data into response body.
        /// </summary>
        /// <param name="rawData">The raw data of response</param>
        /// <returns>The response body of the request</returns>
        public static SeekEntriesResponseBody Parse(byte[] rawData)
        {
            SeekEntriesResponseBody responseBody = new SeekEntriesResponseBody();
            int index = 0;

            responseBody.StatusCode = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index);
            index += sizeof(uint);
            responseBody.HasState = BitConverter.ToBoolean(rawData, index);
            index += sizeof(bool);
            if (responseBody.HasState)
            {
                responseBody.State = STAT.Parse(rawData, ref index);
            }
            else
            {
                responseBody.State = null;
            }

            responseBody.HasColumnsAndRows = BitConverter.ToBoolean(rawData, index);
            index += sizeof(bool);
            if (responseBody.HasColumnsAndRows)
            {
                responseBody.Columns  = LargePropTagArray.Parse(rawData, ref index);
                responseBody.RowCount = BitConverter.ToUInt32(rawData, index);
                responseBody.RowData  = new AddressBookPropertyRow[(uint)responseBody.RowCount];
                index += sizeof(uint);
                for (int i = 0; i < responseBody.RowCount; i++)
                {
                    responseBody.RowData[i] = AddressBookPropertyRow.Parse(rawData, (LargePropTagArray)responseBody.Columns, ref index);
                }
            }
            else
            {
                responseBody.Columns  = null;
                responseBody.RowCount = null;
                responseBody.RowData  = 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);
        }
コード例 #3
0
        /// <summary>
        /// Parse the AddressBookPropertyRow structure.
        /// </summary>
        /// <param name="rawBuffer">The raw data returned from server.</param>
        /// <param name="propTagArray">The list of property tags.</param>
        ///  <param name="index">The start index.</param>
        /// <returns>Return an instance of AddressBookPropertyRow.</returns>
        public static AddressBookPropertyRow Parse(byte[] rawBuffer, LargePropTagArray propTagArray, ref int index)
        {
            AddressBookPropertyRow addressBookPropertyRow = new AddressBookPropertyRow();
            addressBookPropertyRow.Flag = rawBuffer[index];
            index++;
            addressBookPropertyRow.ValueArray = new List<PropertyValue>();

            Context.Instance.PropertyBytes = rawBuffer;
            Context.Instance.CurIndex = index;
            Context.Instance.CurProperty = new Property(PropertyType.PtypUnspecified);

            // If the value of the Flags field is set to 0x00: The array contains either a PropertyValue structure, or a TypedPropertyValue structure.
            // If the value of the Flags field is set to 0x01: The array contains either a FlaggedPropertyValue structure, or a FlaggedPropertyValueWithType structure. 
            if (addressBookPropertyRow.Flag == 0x00)
            {
               foreach (PropertyTag propertyTag in propTagArray.PropertyTags)
               {
                   if (propertyTag.PropertyType == 0x0000)
                   {
                       // If the value of the Flags field is set to 0x00: The array contains a TypedPropertyValue structure, if the type of property is PtyUnspecified.
                       TypedPropertyValue typedPropertyValue = new TypedPropertyValue();
                       typedPropertyValue.Parse(Context.Instance);
                       addressBookPropertyRow.ValueArray.Add(typedPropertyValue);
                       index = Context.Instance.CurIndex;
                   }
                   else
                   {
                       // If the value of the Flags field is set to 0x00: The array contains a PropertyValue structure, if the type of property is specified.
                       Context.Instance.CurProperty.Type = (PropertyType)propertyTag.PropertyType;
                       PropertyValue propertyValue = new PropertyValue();
                       propertyValue.Parse(Context.Instance);
                       addressBookPropertyRow.ValueArray.Add(propertyValue);
                       index = Context.Instance.CurIndex;
                   }
               }
            }
            else if (addressBookPropertyRow.Flag == 0x01)
            {
                foreach (PropertyTag propertyTag in propTagArray.PropertyTags)
                {
                    if (propertyTag.PropertyType == 0x0000)
                    {
                        // If the value of the Flags field is set to 0x01: The array contains a FlaggedPropertyValueWithType structure, if the type of property is PtyUnspecified.
                        FlaggedPropertyValueWithType flaggedPropertyValue = new FlaggedPropertyValueWithType();
                        flaggedPropertyValue.Parse(Context.Instance);
                        addressBookPropertyRow.ValueArray.Add(flaggedPropertyValue);
                        index = Context.Instance.CurIndex;
                    }
                    else
                    {
                        // If the value of the Flags field is set to 0x01: The array contains a FlaggedPropertyValue structure, if the type of property is specified.
                        Context.Instance.CurProperty.Type = (PropertyType)propertyTag.PropertyType;
                        FlaggedPropertyValue propertyValue = new FlaggedPropertyValue();
                        propertyValue.Parse(Context.Instance);
                        addressBookPropertyRow.ValueArray.Add(propertyValue);
                        index = Context.Instance.CurIndex;
                    }
                }
            }

            return addressBookPropertyRow;
        }
コード例 #4
0
        /// <summary>
        /// Parse the AddressBookPropertyRow structure.
        /// </summary>
        /// <param name="rawBuffer">The raw data returned from server.</param>
        /// <param name="propTagArray">The list of property tags.</param>
        ///  <param name="index">The start index.</param>
        /// <returns>Return an instance of AddressBookPropertyRow.</returns>
        public static AddressBookPropertyRow Parse(byte[] rawBuffer, LargePropTagArray propTagArray, ref int index)
        {
            AddressBookPropertyRow addressBookPropertyRow = new AddressBookPropertyRow();

            addressBookPropertyRow.Flag = rawBuffer[index];
            index++;
            addressBookPropertyRow.ValueArray = new List <PropertyValue>();

            Context.Instance.PropertyBytes = rawBuffer;
            Context.Instance.CurIndex      = index;
            Context.Instance.CurProperty   = new Property(PropertyType.PtypUnspecified);

            // If the value of the Flags field is set to 0x00: The array contains either a PropertyValue structure, or a TypedPropertyValue structure.
            // If the value of the Flags field is set to 0x01: The array contains either a FlaggedPropertyValue structure, or a FlaggedPropertyValueWithType structure.
            if (addressBookPropertyRow.Flag == 0x00)
            {
                foreach (PropertyTag propertyTag in propTagArray.PropertyTags)
                {
                    if (propertyTag.PropertyType == 0x0000)
                    {
                        // If the value of the Flags field is set to 0x00: The array contains a TypedPropertyValue structure, if the type of property is PtyUnspecified.
                        TypedPropertyValue typedPropertyValue = new TypedPropertyValue();
                        typedPropertyValue.Parse(Context.Instance);
                        addressBookPropertyRow.ValueArray.Add(typedPropertyValue);
                        index = Context.Instance.CurIndex;
                    }
                    else
                    {
                        // If the value of the Flags field is set to 0x00: The array contains a PropertyValue structure, if the type of property is specified.
                        Context.Instance.CurProperty.Type = (PropertyType)propertyTag.PropertyType;
                        PropertyValue propertyValue = new PropertyValue();
                        propertyValue.Parse(Context.Instance);
                        addressBookPropertyRow.ValueArray.Add(propertyValue);
                        index = Context.Instance.CurIndex;
                    }
                }
            }
            else if (addressBookPropertyRow.Flag == 0x01)
            {
                foreach (PropertyTag propertyTag in propTagArray.PropertyTags)
                {
                    if (propertyTag.PropertyType == 0x0000)
                    {
                        // If the value of the Flags field is set to 0x01: The array contains a FlaggedPropertyValueWithType structure, if the type of property is PtyUnspecified.
                        FlaggedPropertyValueWithType flaggedPropertyValue = new FlaggedPropertyValueWithType();
                        flaggedPropertyValue.Parse(Context.Instance);
                        addressBookPropertyRow.ValueArray.Add(flaggedPropertyValue);
                        index = Context.Instance.CurIndex;
                    }
                    else
                    {
                        // If the value of the Flags field is set to 0x01: The array contains a FlaggedPropertyValue structure, if the type of property is specified.
                        Context.Instance.CurProperty.Type = (PropertyType)propertyTag.PropertyType;
                        FlaggedPropertyValue propertyValue = new FlaggedPropertyValue();
                        propertyValue.Parse(Context.Instance);
                        addressBookPropertyRow.ValueArray.Add(propertyValue);
                        index = Context.Instance.CurIndex;
                    }
                }
            }

            return(addressBookPropertyRow);
        }