Exemple #1
0
        public IEnumerable <Currency> Except(IsoCurrenciesCollection scrapped)
        {
            var except = _currencies.Values.Select(c => !scrapped.Contains(c.NumericCode) ? c : null)
                         .Where(c => c != null);

            return(except);
        }
 public IsoCurrenciesCollection LoadFrom(Uri url)
 {
     using (var client = new WebClient())
     {
         IsoCurrenciesCollection collection = load(client.OpenRead(url));
         return(collection);
     }
 }
        private IsoCurrenciesCollection load(Stream stream)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Iso4217Element));
            var           doc        = (Iso4217Element)serializer.Deserialize(stream);
            var           currencies = new IsoCurrenciesCollection();

            currencies.AddRange(doc.CountryTable.Countries);
            return(currencies);
        }
        public void Run()
        {
            var loader = new IsoCurrenciesLoader();
            IsoCurrenciesCollection         isoCurrencies = loader.LoadFrom(IsoCurrenciesLoader.IsoUrl);
            ImplementedCurrenciesCollection implemented   = new ImplementedCurrenciesCollection()
                                                            .AddRange(Currency.FindAll());

            ConsoleTable implementedOnly = new ConsoleTable("Alpha-Code", "Name", "Obsolete?");
            ConsoleTable isoOnly         = new ConsoleTable("Alpha-Code", "Name", "Minor units");
            ConsoleTable discrepancies   = new ConsoleTable("Alpha-Code", "Name / ISO Name", "Minor units / ISO Units");

            foreach (IsoCurrency iso in isoCurrencies.OrderBy(c => c.AlphabeticalCode, StringComparer.Ordinal))
            {
                Currency currency = implemented[iso.NumericCode.Value.GetValueOrDefault()];
                if (currency != null)
                {
                    CurrencyDiff diff = CurrencyDiff.Diff(currency, iso);
                    if (diff != null)
                    {
                        discrepancies.AddRow(currency.AlphabeticCode, diff.Name, diff.MinorUnits);
                    }
                }
                else
                {
                    isoOnly.AddRow(iso.AlphabeticalCode, iso.Name, iso.MinorUnits.Value);
                }
            }

            foreach (var currency in implemented.Except(isoCurrencies))
            {
                implementedOnly.AddRow(currency.AlphabeticCode, currency.EnglishName, currency.IsObsolete);
            }

            WriteLine("The following currencies are defined only in the implemented set:");
            implementedOnly.Write(Format.Alternative);

            WriteLine("The following currencies are defined only in the ISO web:");
            isoOnly.Write(Format.Alternative);

            WriteLine("The following currencies have different information in the ISO web than the one implemented:");
            discrepancies.Write(Format.Alternative);
        }
        public IsoCurrenciesCollection LoadFrom(FileStream file)
        {
            IsoCurrenciesCollection collection = load(file);

            return(collection);
        }