Beispiel #1
0
 private static void UpdateAPI()
 {
     try {
         var Client       = new WebClient();
         var Response     = Client.DownloadString("http://api.fixer.io/latest?base=USD");
         var LastResponse = JsonConvert.DeserializeObject <CurrencyAPIResponse>(Response, Globals.JsonSettings);
         LastUpdate = DateTime.Now;
         // set that we have a response
         if (LastResponse != null)
         {
             IsCurrencyConverterInit = true;
             CurrencyAPIResponse     = LastResponse;
             ActiveDisplayCurrency   = ConfigManager.GeneralConfig.DisplayCurrency;
         }
     }
     catch (Exception E)
     {
         if (!IsCurrencyConverterInit)
         {
             Helpers.ConsolePrint("CurrencyConverter", E.Message);
             Helpers.ConsolePrint("CurrencyConverter", "Unable to update API: reverting to usd");
             ActiveDisplayCurrency = "USD";
         }
     }
 }
 private static void UpdateAPI()
 {
     try {
         var Client = new WebClient();
         var Response = Client.DownloadString("http://api.fixer.io/latest?base=USD");
         var LastResponse = JsonConvert.DeserializeObject<CurrencyAPIResponse>(Response, Globals.JsonSettings);
         LastUpdate = DateTime.Now;
         // set that we have a response
         if (LastResponse != null) {
             IsCurrencyConverterInit = true;
             CurrencyAPIResponse = LastResponse;
             ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency;
         }
     }
     catch (Exception E)
     {
         if (!IsCurrencyConverterInit) {
             Helpers.ConsolePrint("CurrencyConverter", E.Message);
             Helpers.ConsolePrint("CurrencyConverter", "Unable to update API: reverting to usd");
             ActiveDisplayCurrency = "USD";
         }
     }
 }