The ShortArray_r structure encodes an array of 16-bit integers.
Exemple #1
0
        /// <summary>
        /// Parse ShortArray_r structure.
        /// </summary>
        /// <param name="ptr">A pointer points to memory allocated.</param>
        /// <returns>Instance of ShortArray_r structure.</returns>
        public static ShortArray_r ParseShortArray_r(IntPtr ptr)
        {
            ShortArray_r shortArray = new ShortArray_r
            {
                Values = (uint)Marshal.ReadInt32(ptr)
            };

            if (shortArray.Values == 0)
            {
                shortArray.Lpi = null;
            }
            else
            {
                IntPtr saaddr = new IntPtr(Marshal.ReadInt32(ptr, sizeof(uint)));
                shortArray.Lpi = new short[shortArray.Values];
                int offset = 0;
                for (uint i = 0; i < shortArray.Values; i++, offset += sizeof(short))
                {
                    shortArray.Lpi[i] = Marshal.ReadInt16(saaddr, offset);
                }
            }

            return(shortArray);
        }
        /// <summary>
        /// Parse ShortArray_r structure.
        /// </summary>
        /// <param name="ptr">A pointer points to the allocated memory.</param>
        /// <returns>Instance of ShortArray_r structure.</returns>
        public static ShortArray_r ParseShortArray_r(IntPtr ptr)
        {
            ShortArray_r shortArray = new ShortArray_r
            {
                CValues = (uint)Marshal.ReadInt32(ptr)
            };

            if (shortArray.CValues == 0)
            {
                shortArray.Lpi = null;
            }
            else
            {
                if (AdapterHelper.Transport.ToLower(System.Globalization.CultureInfo.CurrentCulture) != "mapi_http")
                {
                    IntPtr saaddr = new IntPtr(Marshal.ReadInt32(ptr, sizeof(uint)));
                    ptr = saaddr;
                }

                shortArray.Lpi = new short[shortArray.CValues];
                int offset = 0;
                for (uint i = 0; i < shortArray.CValues; i++, offset += sizeof(short))
                {
                    shortArray.Lpi[i] = Marshal.ReadInt16(ptr, offset);
                }
            }

            return shortArray;
        }