Example #1
0
        public void TestValuationPortfolio(List <Asset> assets, IExchangeRates rates, string name, decimal expected, string currency)
        {
            AssetPortfolio portfolio = new AssetPortfolio(rates, name, assets);

            TestValuationPortfolio(portfolio, expected, currency);
            Console.WriteLine(portfolio.ToString());
        }
Example #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var            selectedPair  = (KeyValuePair <string, IExchangeRates>)comboBox.SelectedItem;
            IExchangeRates selectedValue = selectedPair.Value;

            _actualCurrencies   = selectedValue.Get();
            dgMoney.ItemsSource = _actualCurrencies;
        }
        protected override void InitializeObject(IGenericEntity ent)
        {
            if (ent is IExchangeRates)
            {
                IExchangeRates exchangeRates = (IExchangeRates)ent;

                DBStoredProcedure spSelect = new DBStoredProcedure();
                spSelect.ProcedureName = "catSelectExchangeRates";
                spSelect.AddParameter(new DBParameter("@Year", DbType.Int32, ParameterDirection.Input, exchangeRates.Year));
                this.AddStoredProcedure("SelectObject", spSelect);
            }
        }
 /// <summary>
 /// Constructs example of <see cref="ExchangeRatesVm"/>
 /// </summary>
 /// <param name="exchangeRates">Provider of exchange rates data</param>
 /// <exception cref="ArgumentNullException"/>
 public ExchangeRatesVm(IExchangeRates exchangeRates)
 {
     if (exchangeRates == null)
         throw new ArgumentNullException("exchangeRates");
     _exchangeRates = exchangeRates;
     IsSuccesfull = true;
     ErrorMessage = string.Empty;
     Currency = Currency.RUB;
     StartDate = DateTime.Today.AddDays(-10);
     EndDate = DateTime.Today;
     CurrencyList = Currency.RUB.ToSelectList();
 }
Example #5
0
 public CurrencyConverterService(IExchangeRates exchangeRates)
 {
     this.exchangeRates = exchangeRates ?? throw new ArgumentNullException(nameof(exchangeRates));
 }
 public ExchangeService(IExchangeRates exchangeRates)
 {
     _exchangeRates = exchangeRates;
 }
 public AssetPortfolio(IExchangeRates exchangeRates, string name, List <Asset> assets)
 {
     ExchangeRates = exchangeRates;
     Name          = name;
     assets.ForEach(Add);
 }
 public AssetPortfolio(IExchangeRates exchangeRates, string name)
 {
     ExchangeRates = exchangeRates;
     Name          = name;
 }
 public AssetPortfolio(IExchangeRates exchangeRates)
 {
     ExchangeRates         = exchangeRates;
     Portfolio             = new List <IAsset>();
     ConsolidatedPortfolio = new Dictionary <string, IAsset>();
 }
Example #10
0
 /// <summary>
 /// method to value asset in another currency
 /// </summary>
 /// <param name="exchangeRates"></param>
 /// <param name="toCurrency"></param>
 /// <returns></returns>
 public decimal Value(IExchangeRates exchangeRates, string toCurrency)
 {
     return(Value() * exchangeRates.GetRate(Currency, toCurrency));
 }
Example #11
0
        public void LoadModules()
        {
            Debug.WriteLine($"ModulesControl.LoadModules()");
            foreach (var file in _moduleFiles)
            {
                try
                {
                    Debug.WriteLine($"Nahravam modul {file}.");
                    var asm = Assembly.LoadFrom(file);

                    var typeExchangeRates = asm.GetType("wpfapp.ExchangeRates");
                    if (typeExchangeRates.GetInterface("IExchangeRates") == null)
                    {
                        Trace.WriteLine($"Chyba v modulu {file}. Neni naimplementovano pozadovane rozhrani.");
                        ModuleLoadedEventArgs argsE = new ModuleLoadedEventArgs()
                        {
                            Error = true
                        };
                        OnModuleLoaded(argsE);
                    }

                    var propApiName = typeExchangeRates.GetProperty("ApiName");

                    IExchangeRates exRates = (IExchangeRates)Activator.CreateInstance(typeExchangeRates, _httpClient);
                    string         apiName = (string)propApiName.GetValue(exRates, null);

                    if (apiName == null)
                    {
                        Trace.WriteLine($"Chyba v modulu {file}. Knihovna nema nastavene jmeno.");
                        ModuleLoadedEventArgs argsE = new ModuleLoadedEventArgs()
                        {
                            Error = true
                        };
                        OnModuleLoaded(argsE);
                    }

                    _apiDictionary.Add(apiName, exRates);

                    // vyvoláme událost OK
                    Trace.WriteLine($"Modul {file} byl uspesne nacten.");
                    ModuleLoadedEventArgs argsOK = new ModuleLoadedEventArgs()
                    {
                        Error = false
                    };
                    OnModuleLoaded(argsOK);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine($"Knihovnu '{file}' nelze načíst.");

                    // vyvoláme událost ERROR
                    ModuleLoadedEventArgs args = new ModuleLoadedEventArgs()
                    {
                        Error = true
                    };
                    OnModuleLoaded(args);
                }

                // umělé čekání
                Thread.Sleep(1500);
            }
            Debug.WriteLine($"ModulesControl.LoadModules() - KONEC");
        }