Beispiel #1
0
        public CurrencyCalculatorTests()
        {
            _xrProviderMock = new Mock <IExchangeRatesProvider>();

            _currencyCalculator = new CurrencyCalculator(
                _xrProviderMock.Object);
        }
Beispiel #2
0
 public IndexController(IDataRepository dataRepository, ICurrencyValidator currencyValidator, IConfiguration configuraton, ICurrencyCalculator currencyCalculator)
 {
     _dataRepository     = dataRepository;
     _currencyValidator  = currencyValidator;
     AllowedCurrencies   = configuraton.GetValue <string>("AllowedCurrencies");
     _currencyCalculator = currencyCalculator;
 }
 public static ICurrencyCalculator GetCalculator()
 {
     if (calculator == null)
     {
         calculator = new CurrencyCalculatorService();
     }
     return(calculator);
 }
Beispiel #4
0
        public MainWindow()
        {
            this.currencyCalculator = CurrencyCalculatorFactory.GetCalculator();

            this.txtLeftValue = new TextBox()
            {
                Width  = 80,
                Margin = new Thickness(10)
            };

            this.txtRightValue = new TextBox()
            {
                Width  = 80,
                Margin = new Thickness(10)
            };

            this.cmbLeftCurrency = new ComboBox()
            {
                Margin = new Thickness(10)
            };

            this.cmbRightCurrency = new ComboBox()
            {
                Margin = new Thickness(10)
            };

            // Version 1:
            //foreach (var currency in currencyCalculator.GetCurrencyData())
            //{
            //    this.cmbLeftCurrency.Items.Add(currency);
            //    this.cmbRightCurrency.Items.Add(currency);
            //}

            // Version 2:
            var currencies = currencyCalculator.GetCurrencyData();

            this.cmbLeftCurrency.ItemsSource  = currencies;
            this.cmbRightCurrency.ItemsSource = currencies;

            StackPanel panel = new StackPanel();

            panel.Children.Add(txtLeftValue);
            panel.Children.Add(cmbLeftCurrency);
            panel.Children.Add(txtRightValue);
            panel.Children.Add(cmbRightCurrency);

            panel.Orientation = Orientation.Horizontal;

            this.cmbLeftCurrency.SelectedItem  = currencies.Where(p => p.Symbol == "CHF").First();
            this.cmbRightCurrency.SelectedItem = currencies.Where(p => p.Symbol == "EUR").First();

            this.cmbLeftCurrency.SelectionChanged  += OnSelectionChanged;
            this.cmbRightCurrency.SelectionChanged += OnSelectionChanged;

            this.Content = panel;

            this.SizeToContent = SizeToContent.WidthAndHeight;
        }
        public static ICurrencyCalculator GetCalculator()
        {
            if (calc == null)
            {
                calc = new CurrencyCalculator();
            }

            return(calc);
        }
Beispiel #6
0
        public CurrencyCalculatorWindow()
        {
            txtLeftValue = new TextBox()
            {
                Width = 80
            };
            txtRightValue = new TextBox()
            {
                Width = 80
            };
            cmbLeftCurrency = new ComboBox()
            {
                Margin = new Thickness(5, 0, 5, 0)
            };
            cmbRightCurrency = new ComboBox()
            {
                Margin = new Thickness(5, 0, 0, 0)
            };

            StackPanel panel = new StackPanel()
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(10)
            };

            panel.Children.Add(txtLeftValue);
            panel.Children.Add(cmbLeftCurrency);
            panel.Children.Add(txtRightValue);
            panel.Children.Add(cmbRightCurrency);

            this.Content = panel;
            this.Title   = "WPF Currency Converter (Code)";

            // wie sich der content des windows anpassen soll
            this.SizeToContent = SizeToContent.WidthAndHeight;
            this.ResizeMode    = ResizeMode.NoResize;

            this.calculator = CurrencyCalculatorFactory.GetCalculator();

            foreach (CurrencyData currency in calculator.GetCurrencyData())
            {
                cmbLeftCurrency.Items.Add(currency);
                cmbRightCurrency.Items.Add(currency);
            }

            cmbLeftCurrency.SelectedIndex = cmbRightCurrency.SelectedIndex = 0;

            cmbLeftCurrency.SelectionChanged  += OnSelectionChanged;
            cmbRightCurrency.SelectionChanged += OnSelectionChanged;

            txtLeftValue.TextChanged  += OnTextChanged;
            txtRightValue.TextChanged += OnTextChanged;
        }
        public CurrencyCalculatorWindow()
        {
            InitializeComponent();

            calculator = CurrencyCalculatorFactory.GetCalculator();

            IEnumerable <CurrencyData> currencies = calculator.GetCurrencyData();

            cmbLeftCurrency.ItemsSource = cmbRightCurrency.ItemsSource = currencies;

            cmbLeftCurrency.SelectedItem  = currencies.First(c => c.Symbol == "EUR");
            cmbRightCurrency.SelectedItem = currencies.First(c => c.Symbol == "JPY");
        }
Beispiel #8
0
        public MainWindow()
        {
            InitializeComponent();
            currencyCalcualtor = CurrencyCalculatorFactory.GetCalculator();
            var currency = currencyCalcualtor.GetCurrencyData();

            foreach (var currencyData in currency)
            {
                cmbLeftCurrency.Items.Add(currencyData);
                cmbRightCurrency.Items.Add(currencyData);
            }
            cmbLeftCurrency.SelectedItem  = currency.First(c => c.Symbol == "EUR");
            cmbRightCurrency.SelectedItem = currency.First(c => c.Symbol == "USD");
        }
Beispiel #9
0
        public MainWindow()
        {
            InitializeComponent();

            this.currencyCalculator = CurrencyCalculatorFactory.GetCalculator();

            var currencies = this.currencyCalculator.GetCurrencyData();

            this.cmbLeftCurrency.ItemsSource  = currencies;
            this.cmbRightCurrency.ItemsSource = currencies;

            this.cmbLeftCurrency.SelectedIndex  = 0;
            this.cmbRightCurrency.SelectedIndex = 0;

            rates.ItemsSource = this.currencyCalculator.MonthlyRatesOfExchange("CHF", "EUR", new DateTime(2016, 1, 1), new DateTime(2017, 1, 1));
        }
 public HomeController(ICurrencyCalculator calculator)
 {
     _calculator = calculator;
 }
 public HomeController(ILogger <HomeController> logger, ICurrencyCalculator currentCalculator, IInfoService infoService)
 {
     _logger            = logger;
     _currentCalculator = currentCalculator;
     _infoService       = infoService;
 }
 public RetryCurrencyCalculator(ICurrencyCalculator inner, IOptions <Settings> settings)
 {
     _settings = settings.Value;
     _inner    = inner;
 }
 public CachedCurrencyCalculator(ICurrencyCalculator inner, IMemoryCache cache)
 {
     _inner = inner;
     _cache = cache;
 }