private void CreateCMetadata()
        {
            var scid        = MarshalingHelpers.StringToHGlobalUtf8(this.ServiceConfigurationId);
            var path        = MarshalingHelpers.StringToHGlobalUtf8(this.BlobPath);
            var xuid        = MarshalingHelpers.StringToHGlobalUtf8(this.XboxUserId);
            var displayName = MarshalingHelpers.StringToHGlobalUtf8(this.DisplayName);
            var etag        = MarshalingHelpers.StringToHGlobalUtf8(this.ETag);

            IntPtr clientTimePtr = IntPtr.Zero;

            if (this.ClientTimeStamp != null)
            {
                var clientTime = this.ClientTimeStamp.ToUnixTimeSeconds();
                clientTimePtr = Marshal.AllocHGlobal(MarshalingHelpers.SizeOf <UInt64>());
                Marshal.WriteInt64(clientTimePtr, clientTime);
            }

            TitleStorageCreateBlobMetadata(scid, StorageType, path, BlobType, xuid, displayName, etag, clientTimePtr, out metadataPtr);

            Marshal.FreeHGlobal(scid);
            Marshal.FreeHGlobal(path);
            Marshal.FreeHGlobal(xuid);
            Marshal.FreeHGlobal(displayName);
            Marshal.FreeHGlobal(etag);
            Marshal.FreeHGlobal(clientTimePtr);
        }
Exemplo n.º 2
0
        private void CheckMultiplePermissionsWithMultipleTargetUsersComplete(XSAPI_RESULT_INFO result, IntPtr resultsPtr, UInt32 privacyCheckResultCount, IntPtr contextKey)
        {
            XsapiCallbackContext <CheckMultiplePermissionsContext, IList <MultiplePermissionsCheckResult> > context;

            if (XsapiCallbackContext <CheckMultiplePermissionsContext, IList <MultiplePermissionsCheckResult> > .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    var results = new List <MultiplePermissionsCheckResult>();

                    var structSize = MarshalingHelpers.SizeOf <XSAPI_PRIVACY_MULTIPLE_PERMISSIONS_CHECK_RESULT>();
                    for (UInt64 i = 0; i < privacyCheckResultCount; ++i)
                    {
                        results.Add(new MultiplePermissionsCheckResult(resultsPtr));
                        resultsPtr = resultsPtr.Increment(structSize);
                    }
                    context.TaskCompletionSource.SetResult(results.AsReadOnly());
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }
                MarshalingHelpers.FreeHGlobalUtf8StringArray(context.Context.permissionIdsArray, context.Context.permissionIdsLength);
                MarshalingHelpers.FreeHGlobalUtf8StringArray(context.Context.targetXboxUserIdsArray, context.Context.targetXboxUserIdsLength);
                context.Dispose();
            }
        }
        public LeaderboardQuery GetNextQueryImpl()
        {
            // Allocates memory for returned objects
            IntPtr cErrMessage = Marshal.AllocHGlobal(MarshalingHelpers.SizeOf <IntPtr>());
            IntPtr cNextQuery  = Marshal.AllocHGlobal(MarshalingHelpers.SizeOf <IntPtr>());

            // Invokes the c method
            XSAPI_RESULT errCode = LeaderboardResultGetNextQuery(m_leaderboardResultPtr, cNextQuery, cErrMessage);

            // Handles error
            string errMessage = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(cErrMessage));

            Marshal.FreeHGlobal(cErrMessage);

            if (errCode != XSAPI_RESULT.XSAPI_RESULT_OK)
            {
                // todo do something
            }

            // Does local work
            LeaderboardQuery nextQuery = new LeaderboardQuery(Marshal.ReadIntPtr(cNextQuery));

            Marshal.FreeHGlobal(cNextQuery);

            return(nextQuery);
        }
Exemplo n.º 4
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);
            }
        }
        internal MultiplePermissionsCheckResult(IntPtr multiplePermissionsStructPtr)
        {
            var multiplePermissionsStruct = MarshalingHelpers.PtrToStructure <XSAPI_PRIVACY_MULTIPLE_PERMISSIONS_CHECK_RESULT>(multiplePermissionsStructPtr);

            XboxUserId = MarshalingHelpers.Utf8ToString(multiplePermissionsStruct.xboxUserId);

            Items = new List <PermissionCheckResult>((int)multiplePermissionsStruct.itemsCount);

            int    size = MarshalingHelpers.SizeOf <XSAPI_PRIVACY_PERMISSION_CHECK_RESULT>();
            IntPtr permissionStructPtr = multiplePermissionsStruct.items;

            for (ulong i = 0; i < multiplePermissionsStruct.itemsCount; ++i)
            {
                var permissionCheckResultStruct = MarshalingHelpers.PtrToStructure <XSAPI_PRIVACY_PERMISSION_CHECK_RESULT>(permissionStructPtr);
                Items.Add(new PermissionCheckResult(permissionCheckResultStruct));
                permissionStructPtr = permissionStructPtr.Increment(size);
            }
        }