예제 #1
0
 public CurrencyRate(CurrencyCode code, double rate)
 {
     if (rate < 0)
     {
         throw new ArgumentException("rate can't be less than zero!", nameof(rate));
     }
     Code = code;
     Rate = rate;
 }
예제 #2
0
        public double Exchange(double sourceAmount, CurrencyCode sourceCurrencyCode, CurrencyCode destCurrencyCode)
        {
            CurrencyRate sr = this[sourceCurrencyCode];
            CurrencyRate dr = this[destCurrencyCode];

            double relativeRate = dr.Rate / sr.Rate;

            return(sourceAmount * relativeRate);
        }
예제 #3
0
 public CurrencyRate this[CurrencyCode code]
 {
     get
     {
         if (!_data.TryGetValue(code, out var result))
         {
             throw new ArgumentException("Unknown Currency:" + code, nameof(code));
         }
         return(result);
     }
 }
예제 #4
0
 public CurrencyTimeSeries(CurrencyCode currencyCode, IEnumerable<double> data)
 {
     CurrencyCode = currencyCode;
     _data = data.ToArray();
 }
예제 #5
0
 public CurrencyTimeSeries this[CurrencyCode code] => _data[code];