public static void Main(string[] args) { try { var provider = new ExchangeRateProvider(); var rates = provider.GetExchangeRates(currencies); Console.WriteLine("Successfully retrieved " + rates.Count() + " exchange rates:"); foreach (var rate in rates) { Console.WriteLine(rate.ToString()); } } catch (Exception e) { Console.WriteLine("An error occurred while retrieving exchange rates: " + e.Message); } Console.ReadLine(); }
public static void Main(string[] args) { try { var provider = new ExchangeRateProvider(); var rates = provider.GetExchangeRates(currencies); Console.WriteLine($"Successfully retrieved {rates.Count()} exchange rates:"); foreach (var rate in rates) { Console.WriteLine(rate.ToString()); } } catch (Exception e) { Console.WriteLine($"Could not retrieve exchange rates: '{e.Message}'."); } Console.ReadLine(); }
public static async Task Main(string[] args) { try { var provider = new ExchangeRateProvider(new ExchangeRateClient(new HttpClient(), new Configuration())); var rates = provider.GetExchangeRates(currencies); Console.WriteLine($"Successfully retrieved {await rates.CountAsync()} exchange rates:"); await foreach (var rate in rates) { Console.WriteLine(rate.ToString()); } } catch (Exception e) { Console.WriteLine($"Could not retrieve exchange rates: '{e.Message}'."); } Console.ReadLine(); }
public static void Main(string[] args) { try { var provider = new ExchangeRateProvider(); var rates = provider.GetExchangeRates(currencies); Console.WriteLine($"Successfully retrieved {rates.Count()} exchange rates from CNB for {DateTime.Now}:"); Console.WriteLine(); foreach (var rate in rates) { Console.WriteLine(rate.ToString()); } } catch (Exception e) { Console.WriteLine($"Could not retrieve exchange rates: '{e.Message}'."); } Console.WriteLine(); Console.WriteLine("Please press any key to exit the application. Thank you!"); Console.ReadLine(); }
public static void Main(string[] args) { try { var provider = new ExchangeRateProvider( new List <IExchangeRatesSource> { new CnbExchangeRatesSource(new WebClientWrapper(), new Uri(Configuration.CnbExchangeRatesUrl)) }); var rates = provider.GetExchangeRates(currencies); Console.WriteLine("Successfully retrieved " + rates.Count() + " exchange rates:"); foreach (var rate in rates) { Console.WriteLine(rate.ToString()); } } catch (Exception e) { Console.WriteLine("An error occurred while retrieving exchange rates: " + e.Message); } Console.ReadLine(); }
public static void Main(string[] args) { try { var provider = new ExchangeRateProvider(); foreach (DataSourceEnum dataSource in Enum.GetValues(typeof(DataSourceEnum))) { var rates = provider.GetExchangeRates(currencies, dataSource); Console.WriteLine($"Successfully retrieved {rates.Count()} exchange rates from {dataSource.ToString()}:"); foreach (var rate in rates) { Console.WriteLine(rate.ToString()); } Console.WriteLine("//--==--\\"); } } catch (Exception exc) { Console.WriteLine($"An error occurred while retrieving exchange rates: {exc.Message}"); } Console.ReadLine(); }