Example #1
0
        private void showImplementedOnly(IEnumerable <ScrappedCurrency> scrappedCurrencies, IEnumerable <Currency> allCurrencies)
        {
            WL("The following currencies are defined only in the implemented set:");
            IEnumerable <Currency> implementedOnly = allCurrencies.Except(
                scrappedCurrencies.Select(s => s.ToCurrency()).Where(c => c != null));

            foreach (var implemented in implementedOnly)
            {
                WL(ScrappedCurrency.ToString(implemented));
            }
        }
Example #2
0
        public ScrappedCurrenciesCollection SelectCurrencies()
        {
            var currencies = new ScrappedCurrenciesCollection();

            if (_currenciesWereLoaded)
            {
                IExcelDataReader dr = null;
                try
                {
                    dr = ExcelReaderFactory.CreateBinaryReader(File.OpenRead(_cachedFile));
                    var ds = dr.AsDataSet();

                    currencies.Add(
                        ds.Tables[0].AsEnumerable()
                        .Skip(3)                         // first 3 rows do not contain any info
                        .Select(r =>
                    {
                        string code = r[2].ToString(), numericCode = r[3].ToString(), name = r[1].ToString(), decimals = r[4].ToString();
                        return(ScrappedCurrency.IsCode(code) && ScrappedCurrency.IsNumericCode(numericCode) ?
                               new ScrappedCurrency(code, numericCode, name, decimals) :
                               null);
                    })
                        .ToArray());
                }

                finally
                {
                    if (dr != null)
                    {
                        dr.Close();
                        dr.Dispose();
                    }
                }
            }
            return(currencies);
        }