/// <summary>
        /// Creates a List of strings from an unmanaged C-style array of strings.
        /// </summary>
        /// <param name="arrayPtr">Pointer to the C-style string array</param>
        /// <param name="length">Number of strings in the array</param>
        /// <returns></returns>
        internal static IList <string> Utf8StringArrayToStringList(IntPtr arrayPtr, uint length)
        {
            var list = new List <string>((int)length);

            for (int i = 0; i < length; ++i)
            {
                string str = MarshalingHelpers.Utf8ToString(Marshal.ReadIntPtr(arrayPtr));
                list.Add(str);
                arrayPtr = arrayPtr.Increment(IntPtr.Size);
            }
            return(list);
        }
        private static XboxLiveAppConfiguration Load()
        {
            IntPtr appConfigPtr;
            var    result = GetXboxLiveAppConfigSingleton(out appConfigPtr);

            if (result != XSAPI_RESULT.XSAPI_RESULT_OK)
            {
                throw new XboxException(result);
            }

            var appConfigStruct = Marshal.PtrToStructure <XSAPI_XBOX_LIVE_APP_CONFIG>(appConfigPtr);

            return(new XboxLiveAppConfiguration
            {
                TitleId = appConfigStruct.titleId,
                Environment = MarshalingHelpers.Utf8ToString(appConfigStruct.environment),
                Sandbox = MarshalingHelpers.Utf8ToString(appConfigStruct.sandbox),
                ServiceConfigurationId = MarshalingHelpers.Utf8ToString(appConfigStruct.scid)
            });
        }
Beispiel #3
0
 internal XboxException(XSAPI_RESULT_INFO resultInfo)
     : base(string.Format("Xbox Services flat C API return error code {0} with message \"{1}\"", resultInfo.errorCode.ToString("g"), MarshalingHelpers.Utf8ToString(resultInfo.errorMessage)))
 {
 }
 internal XboxException(XSAPI_RESULT result, IntPtr errorMessagePtr)
     : base(string.Format("Xbox Services flat C API return error code {0} with message \"{1}\"", result.ToString("g"), MarshalingHelpers.Utf8ToString(errorMessagePtr)))
 {
 }