public void DestroySocialUserGroup(XboxSocialUserGroup xboxSocialUserGroup) { if (xboxSocialUserGroup == null) { throw new ArgumentNullException("xboxSocialUserGroup"); } // Allocates memory for returned objects IntPtr cErrMessage = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>()); // Invokes the c method XSAPI_RESULT errCode = SocialManagerDestroySocialUserGroup(xboxSocialUserGroup.GetPtr(), 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 m_groups.Remove(xboxSocialUserGroup); }
public void UpdateSocialUserGroup(XboxSocialUserGroup socialGroup, IList <string> users) { if (socialGroup == null) { throw new ArgumentNullException("socialGroup"); } if (users == null) { throw new ArgumentNullException("users"); } // Allocates memory for parameters IntPtr cUserIds = MarshalingHelpers.StringListToHGlobalUtf8StringArray(users); // Allocates memory for returned objects IntPtr cErrMessage; // Invokes the c method XSAPI_RESULT errCode = SocialManagerUpdateSocialUserGroup(socialGroup.GetPtr(), cUserIds, (uint)users.Count, out cErrMessage); MarshalingHelpers.FreeHGlobalUtf8StringArray(cUserIds, users.Count); if (errCode != XSAPI_RESULT.XSAPI_RESULT_OK) { throw new XboxException(errCode, cErrMessage); } // Does local work socialGroup.Refresh(); }
public void UpdateSocialUserGroup(XboxSocialUserGroup socialGroup, IList <string> users) { if (socialGroup == null) { throw new ArgumentNullException("socialGroup"); } if (users == null) { throw new ArgumentNullException("users"); } // Allocates memory for parameters List <IntPtr> userIdPtrs = new List <IntPtr>(); for (int i = 0; i < users.Count; i++) { IntPtr cXuid = Marshal.StringToHGlobalUni(users[i]); userIdPtrs.Add(cXuid); } IntPtr cUserIds = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>() * users.Count); Marshal.Copy(userIdPtrs.ToArray(), 0, cUserIds, users.Count); // Allocates memory for returned objects IntPtr cErrMessage = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>()); // Invokes the c method XSAPI_RESULT errCode = SocialManagerUpdateSocialUserGroup(socialGroup.GetPtr(), cUserIds, (uint)users.Count, cErrMessage); // Handles error string errMessage = Marshal.PtrToStringUni(Marshal.ReadIntPtr(cErrMessage)); Marshal.FreeHGlobal(cErrMessage); if (errCode != XSAPI_RESULT.XSAPI_RESULT_OK) { // todo do something } // Cleans up parameters foreach (IntPtr ptr in userIdPtrs) { Marshal.FreeHGlobal(ptr); } Marshal.FreeHGlobal(cUserIds); // Does local work socialGroup.Refresh(); }
public void DestroySocialUserGroup(XboxSocialUserGroup xboxSocialUserGroup) { if (xboxSocialUserGroup == null) { throw new ArgumentNullException("xboxSocialUserGroup"); } IntPtr cErrMessage; // Invokes the c method XSAPI_RESULT errCode = SocialManagerDestroySocialUserGroup(xboxSocialUserGroup.GetPtr(), out cErrMessage); if (errCode != XSAPI_RESULT.XSAPI_RESULT_OK) { throw new XboxException(errCode, cErrMessage); } // Does local work m_groups.Remove(xboxSocialUserGroup); }