예제 #1
0
        public static CurrencyDiff Diff(Currency currency, IsoCurrency scrapped)
        {
            CurrencyDiff diff = null;

            if (!_cmp.Equals(currency.EnglishName, scrapped.Name))
            {
                diff = new CurrencyDiff
                {
                    Name = $"'{currency.EnglishName}' / '{scrapped.Name}'"
                };
            }

            if (!scrapped.MinorUnits.Equals(currency.SignificantDecimalDigits))
            {
                diff            = diff ?? new CurrencyDiff();
                diff.MinorUnits = $"{currency.SignificantDecimalDigits} / {scrapped.MinorUnits}";
            }
            return(diff);
        }
예제 #2
0
        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);
        }