public async Task InitAsync()
        {
            if (this._initialized)
            {
                return;
            }
            using (HttpClient client = new HttpClient((HttpMessageHandler)HttpClientHelpers.GetClientHandler(true)))
            {
                HttpResponseMessage async = await client.GetAsync(this._descriptorUrl);

                if (async.IsSuccessStatusCode)
                {
                    this._descriptor = (ConfigurationDescriptor)JsonConvert.DeserializeObject <ConfigurationDescriptor>(await async.Content.ReadAsStringAsync());
                    switch (ConfigurationRepository.EnvironmentSetting.Environment)
                    {
                    case Ekreta.Mobile.Core.Models.Environments.Environments.PROD:
                        ConfigurationRepository.EnvironmentSetting.GlobalMobileApiUrl = "https://kretaglobalmobileapi2.ekreta.hu";
                        break;

                    case Ekreta.Mobile.Core.Models.Environments.Environments.UAT:
                        ConfigurationRepository.EnvironmentSetting.GlobalMobileApiUrl = this._descriptor.GlobalMobileApiUrlUAT;
                        break;

                    case Ekreta.Mobile.Core.Models.Environments.Environments.TEST:
                        ConfigurationRepository.EnvironmentSetting.GlobalMobileApiUrl = this._descriptor.GlobalMobileApiUrlTEST;
                        break;

                    case Ekreta.Mobile.Core.Models.Environments.Environments.DEV:
                        ConfigurationRepository.EnvironmentSetting.GlobalMobileApiUrl = this._descriptor.GlobalMobileApiUrlDEV;
                        break;
                    }
                    this._initialized = true;
                }
            }
        }
예제 #2
0
 private HttpClient BuildHttpClient()
 {
     return(new HttpClient((HttpMessageHandler)HttpClientHelpers.GetClientHandler(true))
     {
         DefaultRequestHeaders =
         {
             AcceptEncoding =
             {
                 new StringWithQualityHeaderValue("gzip")
             }
         }
     });
 }
 private Task GetVersionData()
 {
     try
     {
         if (this._data != null)
         {
             return((Task)Task.FromResult <AppVersionData>(this._data));
         }
         using (HttpClient httpClient = new HttpClient((HttpMessageHandler)HttpClientHelpers.GetClientHandler(true)))
             this._data = (AppVersionData)JsonConvert.DeserializeObject <AppVersionData>(httpClient.GetStringAsync(this._blob).GetAwaiter().GetResult());
     }
     catch (Exception ex)
     {
         CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, nameof(GetVersionData), "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/AppVersionService.cs", 146);
     }
     return((Task)Task.FromResult <AppVersionData>(this._data));
 }
예제 #4
0
 private HttpClient BuildHttpClient(Profile profile)
 {
     return(new HttpClient((HttpMessageHandler) new AuthMessageHandler(this._mobileApi, this._secureStore, profile, (HttpMessageHandler)HttpClientHelpers.GetClientHandler(true)), true)
     {
         DefaultRequestHeaders =
         {
             AcceptEncoding =
             {
                 new StringWithQualityHeaderValue("gzip")
             }
         },
         Timeout = TimeSpan.FromSeconds((double)ConfigurationRepository.EnvironmentSetting.HttpTimeoutInSeconds)
     });
 }