コード例 #1
0
        // Retrieves the number of highlights given the group ID and filtering params
        public static void GetNumberOfHighlights(GroupView groupView, GetNumberOfHighlightsCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot get number of highlights. The SDK has not been initialized.");
                return;
            }

            GroupViewInternal spi = new GroupViewInternal();

            spi.groupId            = groupView.GroupId;
            spi.significanceFilter = (int)groupView.SignificanceFilter;
            spi.tagFilter          = (int)groupView.TagFilter;

            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(spi));

            GetNumberOfHighlightsCallbackId cid = new GetNumberOfHighlightsCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr pntid = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                Marshal.StructureToPtr(spi, pnt, false);
                Marshal.StructureToPtr(cid, pntid, false);
                Highlights_GetNumberOfHighlightsAsync(pnt, pntid);
            }
            finally
            {
                Marshal.FreeHGlobal(pnt);
                Marshal.FreeHGlobal(pntid);
            }
        }
コード例 #2
0
        // Opens up Summary Dialog for one or more groups
        public static void OpenSummary(GroupView[] summaryParams, EmptyCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot open summary. The SDK has not been initialized.");
                return;
            }

            List <IntPtr> allocatedMemory = new List <IntPtr>();
            IntPtr        nativeArray     = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * summaryParams.Length);

            EmptyCallbackId cid = new EmptyCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr asyncOp = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                for (int i = 0; i < summaryParams.Length; ++i)
                {
                    GroupViewInternal gvi = new GroupViewInternal();
                    gvi.groupId            = summaryParams[i].GroupId;
                    gvi.significanceFilter = (int)(summaryParams[i]).SignificanceFilter;
                    gvi.tagFilter          = (int)(summaryParams[i]).TagFilter;

                    IntPtr nativeSummaryParams = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(GroupViewInternal)));
                    allocatedMemory.Add(nativeSummaryParams);
                    Marshal.StructureToPtr(gvi, nativeSummaryParams, false);
                    Marshal.WriteIntPtr(nativeArray, Marshal.SizeOf(typeof(IntPtr)) * i, nativeSummaryParams);
                }

                Marshal.StructureToPtr(cid, asyncOp, false);

                Highlights_OpenSummaryAsync(summaryParams.Length, nativeArray, asyncOp);
            }
            finally
            {
                Marshal.FreeHGlobal(nativeArray);
                Marshal.FreeHGlobal(asyncOp);

                foreach (IntPtr ptr in allocatedMemory)
                {
                    Marshal.FreeHGlobal(ptr);
                }
            }
        }