コード例 #1
0
 public void UpdateCurrency(Currency currency)
 {
     var targetCurrency = _currencies.Find(c => c.CurrencyChar3Code == currency.CurrencyChar3Code.ToUpper());
     _currencies.Remove(targetCurrency);
     
     _currencies.Add(currency);
     Persist();
 }
コード例 #2
0
        public FlatFileCurrencyReferenceDataRepository(string fileName)
        {
            _fileName = fileName;
            _currencies = new List<Currency>();

            string[] rawCurrencies = File.ReadAllLines(_fileName);

            foreach (var properties in rawCurrencies.Select(rawCurrency => rawCurrency.Split(',')))
            {
                var currency = new Currency
                {
                    CurrencyName = properties[0],
                    CurrencyChar3Code = properties[1],
                    CurrencyNumberCode = Parse(properties[2]),
                };

                int result;
                if(TryParse(properties[3], out result))
                    currency.NumberOfDigits = result; 
                
                _currencies.Add(currency);
            }
        }
コード例 #3
0
 public void AddCurrency(Currency currency)
 {
     _currencies.Add(currency);
     Persist();
 }