예제 #1
0
 public object Get(string key)
 {
     if (!string.IsNullOrWhiteSpace(key))
     {
         return(SerializerHelper.FromJson <object>(_cache.StringGet(GetKeyForRedis(key))));
     }
     throw new NotImplementedException();
 }
예제 #2
0
 public T Get <T>(string key) where T : class
 {
     if (!string.IsNullOrWhiteSpace(key))
     {
         return(SerializerHelper.FromJson <T>(_cache.StringGet(GetKeyForRedis(key))));
     }
     throw new NotImplementedException();
 }
예제 #3
0
        public T GetValue <T>(string key, T defaultValue)
        {
            T value;

            if (Preferences.ContainsKey(key))
            {
                value = SerializerHelper.FromJson <T>(Preferences.Get(key, defaultValue.ToString()).ToString());
            }
            else
            {
                value = defaultValue;
            }
            return(value);
        }
예제 #4
0
        public async Task <ResponseInfo <CurrencyRatesHistoryResponse> > GetRatesHistoryByRange(string baseCode, string targetCode, string range, string interval)
        {
            var url    = $"{AppConfigurations.ApiUrl}GetHistoryRatesByRange?baseCode={baseCode}&targetCode={targetCode}&range={range}&interval={interval}&api-version=1.0";
            var result = new ResponseInfo <CurrencyRatesHistoryResponse>();

            try
            {
                var response = await _httpClientService.CreateClient().GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    var responseString = await response.Content.ReadAsStringAsync();

                    result = SerializerHelper.FromJson <ResponseInfo <CurrencyRatesHistoryResponse> >(responseString);
                }
                return(result);
            }
            catch
            {
                result.Message = "Service unavailable.";
                return(result);
            }
        }