public static IsValid ( string symbol ) : bool | ||
symbol | string | |
Результат | bool |
private static async Task <ExchangeRate> GetRateAsync(string apiKey, string from, string to, DateTime?date = null) { from = from.ToUpper(); to = to.ToUpper(); if (!Symbols.IsValid(from)) { throw new ArgumentException("Symbol not found for provided currency", "from"); } if (!Symbols.IsValid(to)) { throw new ArgumentException("Symbol not found for provided currency", "to"); } var url = GetFixerUrl(apiKey, date); using (var client = new HttpClient()) { var response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); return(ParseData(await response.Content.ReadAsStringAsync(), from, to)); } }
private static ExchangeRate GetRate(string from, string to, DateTime?date = null) { from = from.ToUpper(); to = to.ToUpper(); if (!Symbols.IsValid(from)) { throw new ArgumentException("Symbol not found for provided currency", "from"); } if (!Symbols.IsValid(to)) { throw new ArgumentException("Symbol not found for provided currency", "to"); } var rates = GetLatestRates(date); var fromRate = rates.Value <double>(from); var toRate = rates.Value <double>(to); var rate = toRate / fromRate; return(new ExchangeRate(from, to, rate)); }