Esempio n. 1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            var textL        = cbbLeft.Text.Trim().ToUpper();
            var textR        = cbbRight.Text.Trim().ToUpper();
            var currencyFrom = _fromLeftToRight ? textL : textR;
            var currencyTo   = _fromLeftToRight ? textR : textL;

            if (!cbbLeft.Items.Contains(currencyFrom))
            {
                MessageBox.Show(this, $"Source currency [{currencyFrom}] is not in the list!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!cbbRight.Items.Contains(currencyTo))
            {
                MessageBox.Show(this, $"Target currency [{currencyTo}] is not in the list!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (currencyFrom == currencyTo)
            {
                MessageBox.Show(this, "Source and target currency can't be same!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _exchangeRateRetriever = Factory.NewExchangeRateRetriever(currencyFrom, currencyTo);
            _exchangeRateRetriever.StatusChanged       += _exchangeRateRetriever_StatusChanged;
            _exchangeRateRetriever.ExchangeRateChanged += _exchangeRateRetriever_ExchangeRateChanged;
            _exchangeRateRetriever.Start();
        }
        public StooqExchangeProcessor(IExchangeRateArchiveManager archiveManager,
                                      IExchangeRateDownloader exchangeDownloader,
                                      IExchangeRateRetriever exchangeRateRetriever,
                                      ILogger logger)
        {
            _exchangeRateRetriever = exchangeRateRetriever;
            _exchangeDownloader    = exchangeDownloader;
            _archiveManager        = archiveManager;
            _logger            = logger;
            _exchangeRateNames = new List <string>()
            {
                "wig", "wig20", "fw20", "mwig40", "swig80"
            };
            _exchangeRates = new List <ExchangeRate>();

            foreach (var name in _exchangeRateNames) //initialization of ExchangeRate objects
            {
                _exchangeRates.Add(new ExchangeRate {
                    Name = name
                });
            }
        }
 public SimpleExchangeRateCalculator(IExchangeRateRetriever exchangeRateRetriever)
 {
     _exchangeRateRetriever = exchangeRateRetriever;
 }