Microsoft.Protocols.TestSuites.MS_OXORULE.AdapterHelper.ParseShortArray_r C# (CSharp) Method

ParseShortArray_r() public static method

Parse ShortArray_r structure.
public static ParseShortArray_r ( IntPtr ptr ) : ShortArray_r
ptr System.IntPtr A pointer points to the allocated memory.
return ShortArray_r
        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;
        }