Ejemplo n.º 1
0
        private XboxLive()
        {
            this.settings = new XboxLiveSettings();

            try
            {
                this.appConfig = XboxLiveAppConfiguration.Instance;
            }
            catch (FileLoadException)
            {
                this.appConfig = null;
            }

#if NETFX_CORE
            string fileName = @"\Microsoft.Xbox.Services.140.UWP.C.dll";
            try
            {
                string path = Directory.GetCurrentDirectory() + fileName;
                xsapiNativeDll = LoadNativeDll(path);

                var intializationResult = this.Invoke <XsapiResult, XBLGlobalInitialize>();
                // TODO handle this better
            }
            catch (Exception)
            {
                throw new XboxException("Failed to load " + fileName);
            }
#endif
        }
        internal XboxLiveHttpRequest(string method, string serverName, string pathQueryFragment)
        {
            this.Method            = method;
            this.Url               = serverName + pathQueryFragment;
            this.contextSettings   = XboxLive.Instance.Settings;
            this.webRequest        = (HttpWebRequest)WebRequest.Create(new Uri(this.Url));
            this.webRequest.Method = method;

            this.SetCustomHeader("Accept-Language", CultureInfo.CurrentUICulture + "," + CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);
#if WINDOWS_UWP
            this.SetCustomHeader("Accept", "*/*");
#else
            this.webRequest.Accept = "*/*";
#endif
            this.SetCustomHeader("Cache-Control", "no-cache");
            this.ContentType = "application/json; charset=utf-8";

            const string userAgentType = "XboxServicesAPI";
#if !WINDOWS_UWP
            string userAgentVersion = typeof(XboxLiveHttpRequest).Assembly.GetName().Version.ToString();
#else
            string userAgentVersion = typeof(XboxLiveHttpRequest).GetTypeInfo().Assembly.GetName().Version.ToString();
#endif
            this.SetCustomHeader("UserAgent", userAgentType + "/" + userAgentVersion);
        }
Ejemplo n.º 3
0
        private XboxLive()
        {
            this.settings = new XboxLiveSettings();

            try
            {
                this.appConfig = XboxLiveAppConfiguration.Instance;
            }
            catch (FileLoadException)
            {
                this.appConfig = null;
            }
        }
Ejemplo n.º 4
0
        private XboxLive()
        {
            this.settings = new XboxLiveSettings();

            try
            {
                this.appConfig = XboxLiveAppConfiguration.Instance;
            }
            catch (FileLoadException)
            {
                this.appConfig = null;
            }

#if WINDOWS_UWP
            var result = XBLGlobalInitialize();
            if (result != XSAPI_RESULT.XSAPI_RESULT_OK)
            {
                throw new XboxException(result);
            }
#endif
        }
        internal XboxLiveHttpResponse(
            int httpStatusCode,
            bool networkFailure,
            HttpWebResponse response,
            DateTime responseReceivedTime,
            DateTime requestStartTime,
            string xboxUserId,
            XboxLiveSettings contextSettings,
            string url,
            XboxLiveAPIName xboxLiveAPI,
            string method,
            string requestBody,
            HttpCallResponseBodyType responseBodyType
            )
        {
            this.HttpStatus           = httpStatusCode;
            this.NetworkFailure       = networkFailure;
            this.response             = response;
            this.ResponseReceivedTime = responseReceivedTime;
            this.RequestStartTime     = requestStartTime;
            this.XboxUserId           = xboxUserId;
            this.ContextSettings      = contextSettings;
            this.Url              = url;
            this.XboxLiveAPI      = xboxLiveAPI;
            this.Method           = method;
            this.RequestBody      = requestBody;
            this.ResponseBodyType = responseBodyType;

            if (response != null)
            {
                using (Stream body = response.GetResponseStream())
                {
                    this.Initialize((int)response.StatusCode, body, response.ContentLength, "utf-8", response.Headers);
                }
            }
        }