The PropertyRow_r structure is an encoding of the StandardPropertyRow data structure.
Ejemplo n.º 1
0
        /// <summary>
        /// Parse PropertyRow_r structure.
        /// </summary>
        /// <param name="ptr">A pointer points to memory allocated.</param>
        /// <returns>Instance of PropertyRow_r structure.</returns>
        public static PropertyRow_r ParsePropertyRow_r(IntPtr ptr)
        {
            PropertyRow_r protertyRow = new PropertyRow_r();
            int           offset      = 0;

            protertyRow.Reserved = (uint)Marshal.ReadInt32(ptr);
            offset += sizeof(uint);

            protertyRow.Values = (uint)Marshal.ReadInt32(ptr, offset);
            offset            += sizeof(uint);

            if (protertyRow.Values == 0)
            {
                protertyRow.Props = null;
            }
            else
            {
                protertyRow.Props = new PropertyValue_r[protertyRow.Values];
                IntPtr    pvaddr = new IntPtr(Marshal.ReadInt32(ptr, offset));
                const int PropertyValueLengthInBytes = 16;
                for (uint i = 0; i < protertyRow.Values; i++)
                {
                    protertyRow.Props[i] = ParsePropertyValue_r(pvaddr);
                    pvaddr = new IntPtr(pvaddr.ToInt32() + PropertyValueLengthInBytes);
                }
            }

            return(protertyRow);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allocate memory for the Table row.
        /// </summary>
        /// <param name="propertyRow">Instance of table row structure.</param>
        /// <returns>A pointer points to memory allocated.</returns>
        public static IntPtr AllocPropertyRow_r(PropertyRow_r propertyRow)
        {
            IntPtr ptr    = Marshal.AllocHGlobal(12);
            int    offset = 0;

            Marshal.WriteInt32(ptr, offset, (int)propertyRow.Reserved);
            offset += sizeof(uint);
            Marshal.WriteInt32(ptr, offset, (int)propertyRow.Values);
            offset += sizeof(uint);

            IntPtr pv = AllocPropertyValue_rs(propertyRow.Props);

            Marshal.WriteInt32(ptr, offset, pv.ToInt32());

            return(ptr);
        }
        /// <summary>
        /// Parse PropertyRow_r structure.
        /// </summary>
        /// <param name="ptr">A pointer points to the allocated memory.</param>
        /// <returns>Instance of PropertyRow_r structure.</returns>
        public static PropertyRow_r ParsePropertyRow_r(IntPtr ptr)
        {
            PropertyRow_r protertyRow = new PropertyRow_r();
            int offset = 0;

            protertyRow.Reserved = (uint)Marshal.ReadInt32(ptr);
            offset += sizeof(uint);

            protertyRow.Values = (uint)Marshal.ReadInt32(ptr, offset);
            offset += sizeof(uint);

            if (protertyRow.Values == 0)
            {
                protertyRow.Props = null;
            }
            else
            {
                protertyRow.Props = new PropertyValue_r[protertyRow.Values];
                IntPtr pvaddr = new IntPtr(Marshal.ReadInt32(ptr, offset));

                const int PropertyValueLengthInBytes = 16;

                for (uint i = 0; i < protertyRow.Values; i++)
                {
                    protertyRow.Props[i] = ParsePropertyValue_r(pvaddr);
                    pvaddr = new IntPtr(pvaddr.ToInt32() + PropertyValueLengthInBytes);
                }
            }

            return protertyRow;
        }
        /// <summary>
        /// Parse the PropertyRow_r structure.
        /// </summary>
        /// <param name="row">The row which contains property tags and property values</param>
        /// <returns>Instance of the PropertyRow_r.</returns>
        public static PropertyRow_r ParsePropertyRow_r(AddressBookPropValueList row)
        {
            PropertyRow_r propertyRow_r = new PropertyRow_r();
            propertyRow_r.Reserved = 0;
            propertyRow_r.Values = row.PropertyValueCount;
            propertyRow_r.Props = new PropertyValue_r[row.PropertyValueCount];
            for (int i = 0; i < row.PropertyValueCount; i++)
            {
                propertyRow_r.Props[i].PropTag = BitConverter.ToUInt32(row.PropertyValues[i].PropertyTag.Serialize(), 0);
                propertyRow_r.Props[i].Reserved = 0;
                propertyRow_r.Props[i].Value = AdapterHelper.ParsePROP_VAL_UNION((AddressBookPropertyValue)row.PropertyValues[i], (PropertyTypeValue)row.PropertyValues[i].PropertyTag.PropertyType);
            }

            return propertyRow_r;
        }