private MLResult InitiateItemDetailsQuery(ulong handle, string[] itemIds) { // Allocate memory for query int size = Marshal.SizeOf(typeof(IntPtr)); IntPtr itemIdsPtr = Marshal.AllocHGlobal(size * itemIds.Length); for (int i = 0; i < itemIds.Length; i++) { IntPtr idPtr = Marshal.StringToHGlobalAuto(itemIds[i]); Marshal.WriteIntPtr(new IntPtr(itemIdsPtr.ToInt64() + (Marshal.SizeOf(typeof(IntPtr)) * i)), idPtr); } // Build the query MLPurchaseItemDetailsQuery query = new MLPurchaseItemDetailsQuery() { ids = itemIdsPtr, idCount = Convert.ToUInt32(itemIds.Length) }; // Perform the query MLResult.Code detailsResult = MLPurchaseNativeBindings.MLPurchaseItemDetailsGet(handle, ref query); MLResult result = MLResult.Create(detailsResult); // Free up memory before checking results of query for (int i = 0; i < itemIds.Length; i++) { IntPtr idPtr = Marshal.ReadIntPtr(new IntPtr(itemIdsPtr.ToInt64() + (Marshal.SizeOf(typeof(IntPtr)) * i))); Marshal.FreeHGlobal(idPtr); } Marshal.FreeHGlobal(itemIdsPtr); return(result); }
public static extern MLResult.Code MLPurchaseItemDetailsGet(ulong itemDetailsHandle, ref MLPurchaseItemDetailsQuery request);