Exemple #1
0
        internal PermissionCheckResult(XSAPI_PRIVACY_PERMISSION_CHECK_RESULT permissionCheckResultStruct)
        {
            IsAllowed           = permissionCheckResultStruct.isAllowed;
            PermissionRequested = MarshalingHelpers.Utf8ToString(permissionCheckResultStruct.permissionRequested);

            Reasons = new List <PermissionDenyReason>((int)permissionCheckResultStruct.denyReasonsCount);

            int    size          = MarshalingHelpers.SizeOf <XSAPI_PRIVACY_PERMISSION_DENY_REASON>();
            IntPtr denyReasonPtr = permissionCheckResultStruct.denyReasons;

            for (ulong i = 0; i < permissionCheckResultStruct.denyReasonsCount; ++i)
            {
                Reasons.Add(new PermissionDenyReason(denyReasonPtr));
                denyReasonPtr = denyReasonPtr.Increment(size);
            }
        }
Exemple #2
0
        private void CheckPermissionWithTargetUserComplete(XSAPI_RESULT_INFO result, XSAPI_PRIVACY_PERMISSION_CHECK_RESULT payload, IntPtr contextKey)
        {
            XsapiCallbackContext <object, PermissionCheckResult> context;

            if (XsapiCallbackContext <object, PermissionCheckResult> .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    context.TaskCompletionSource.SetResult(new PermissionCheckResult(payload));
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }
                context.Dispose();
            }
        }