Exemplo n.º 1
0
        private decimal[] GetY(DateTime fromDateInput, DateTime toDateInput, int[] xValues, string fromCurrency, string toCurrency)
        {
            IList <decimal>             yValues = new List <decimal>();
            IDictionary <int, DateTime> dates   = CreateDateSet(fromDateInput, toDateInput);

            foreach (int xValue in xValues)
            {
                ExchangeRate exhangeRate = _reader.Read(dates[xValue], fromCurrency);
                if (!exhangeRate.rates.ContainsKey(toCurrency))
                {
                    throw new ArgumentException($"Currency code {toCurrency} is invalid.");
                }

                decimal yValue = Decimal.Parse(exhangeRate.rates[toCurrency].ToString());

                yValues.Add(yValue);
            }

            return(yValues.ToArray());
        }