コード例 #1
0
ファイル: Fixer.cs プロジェクト: kwestground/FixerSharp
        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));
        }