Пример #1
0
        /// <summary>
        /// Get the number of sepecific structure.
        /// </summary>
        /// <param name="propertyType">The property type of specific structure.</param>
        /// <param name="arrayPropType">The property type of specific structure array.</param>
        /// <param name="body">The body of ObjectSpaceObjectPropSet structure.</param>
        /// <returns>Returns the number of the specififc structrue.</returns>
        private int GetNumberOfSpecificProperty(uint propertyType, uint arrayPropType, PropertySet body)
        {
            int number = 0;

            for (int i = 0; i < body.RgPrids.Length; i++)
            {
                PropertyID propId = body.RgPrids[i];

                if (propId.Type == propertyType)
                {
                    number += 1;
                }
                else if (propId.Type == arrayPropType)
                {
                    ArrayNumber arrayNumber = body.RgData[i] as ArrayNumber;
                    number += (int)arrayNumber.Number;
                }
                else if (propId.Type == 0x10)
                {
                    PrtArrayOfPropertyValues prtArrayOfPropertyValues = body.RgData[i] as PrtArrayOfPropertyValues;
                    for (int j = 0; j < prtArrayOfPropertyValues.CProperties; j++)
                    {
                        number += GetNumberOfSpecificProperty(propertyType, arrayPropType, prtArrayOfPropertyValues.Data[j]);
                    }
                }
                else if (propId.Type == 0x11)
                {
                    PropertySet propSet = body.RgData[i] as PropertySet;
                    number += GetNumberOfSpecificProperty(propertyType, arrayPropType, propSet);
                }
            }

            return(number);
        }
Пример #2
0
        /// <summary>
        /// This method is used to deserialize the PropertySet from the specified byte array and start index.
        /// </summary>
        /// <param name="byteArray">Specify the byte array.</param>
        /// <param name="startIndex">Specify the start index from the byte array.</param>
        /// <returns>Return the length in byte of the PropertySet.</returns>
        public int DoDeserializeFromByteArray(byte[] byteArray, int startIndex)
        {
            int index = startIndex;

            this.CProperties = BitConverter.ToUInt16(byteArray, index);
            index           += 2;
            this.RgPrids     = new PropertyID[this.CProperties];
            for (int i = 0; i < this.CProperties; i++)
            {
                PropertyID propertyID = new PropertyID();
                propertyID.DoDeserializeFromByteArray(byteArray, index);
                this.RgPrids[i] = propertyID;
                index          += 4;
            }
            this.RgData = new List <IProperty>();
            foreach (PropertyID propertyID in this.RgPrids)
            {
                IProperty property = null;
                switch ((PropertyType)propertyID.Type)
                {
                case PropertyType.NoData:
                case PropertyType.Bool:
                case PropertyType.ObjectID:
                case PropertyType.ContextID:
                case PropertyType.ObjectSpaceID:
                    property = new NoData();
                    break;

                case PropertyType.ArrayOfObjectIDs:
                case PropertyType.ArrayOfObjectSpaceIDs:
                case PropertyType.ArrayOfContextIDs:
                    property = new ArrayNumber();
                    break;

                case PropertyType.OneByteOfData:
                    property = new OneByteOfData();
                    break;

                case PropertyType.TwoBytesOfData:
                    property = new TwoBytesOfData();
                    break;

                case PropertyType.FourBytesOfData:
                    property = new FourBytesOfData();
                    break;

                case PropertyType.EightBytesOfData:
                    property = new EightBytesOfData();
                    break;

                case PropertyType.FourBytesOfLengthFollowedByData:
                    property = new PrtFourBytesOfLengthFollowedByData();
                    break;

                case PropertyType.ArrayOfPropertyValues:
                    property = new PrtArrayOfPropertyValues();
                    break;

                case PropertyType.PropertySet:
                    property = new PropertySet();
                    break;

                default:
                    break;
                }
                if (property != null)
                {
                    int len = property.DoDeserializeFromByteArray(byteArray, index);
                    this.RgData.Add(property);
                    index += len;
                }
            }

            return(index - startIndex);
        }