public void AddRate(CurrencyKey key, decimal rate) { if (!_rates.ContainsKey(key)) { _rates.Add(key, rate); } }
public decimal GetRate(string fromCurrency, string toCurrency) { if (fromCurrency == toCurrency) { return(1); } CurrencyKey key = new CurrencyKey(fromCurrency, toCurrency); if (_rates.ContainsKey(key)) { return(_rates[key]); } throw new Exception($"Currency pair {key.FromCurrency} {key.ToCurrency} is not contained"); }