Exemplo n.º 1
0
 public void Load()
 {
     try
     {
         StreamReader file = new StreamReader(Constant.LATEST_RATES_PATH, System.Text.Encoding.UTF8);
         string       json = file.ReadToEnd();
         this.Rates = JsonConvert.DeserializeObject <RatesRaw>(json);
         file.Close();
     }
     catch (IOException ioe)
     {
         throw ioe;
     }
     catch (JsonException je)
     {
         throw je;
     }
 }
Exemplo n.º 2
0
 public void Update()
 {
     try
     {
         HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Constant.RATES_API);
         request.Method  = "GET";
         request.Timeout = 20000;
         HttpWebResponse res    = (HttpWebResponse)request.GetResponse();
         StreamReader    stream = new StreamReader(res.GetResponseStream());
         string          json   = stream.ReadToEnd();
         this.Rates = JsonConvert.DeserializeObject <RatesRaw>(json);
     }
     catch (WebException e)
     {
         throw e;
     }
     catch (JsonException je)
     {
         throw je;
     }
 }