public static IEnumerable <Currency> FindAll() { CurrencyIsoCode[] isoCodes = Enumeration.GetValues <CurrencyIsoCode>(); using (var initializer = CurrencyInfo.CreateInitializer()) { for (int i = 0; i < isoCodes.Length; i++) { CurrencyIsoCode isoCode = isoCodes[i]; var copy = initializer; Currency currency = _cache.GetOrAdd(isoCode, () => init(isoCode, copy.Get)); RaiseIfObsolete(isoCode); yield return(currency); } } }
/// <summary> /// Initialized static shortcuts and caches /// </summary> static Currency() { _provider = CurrencyInfo.CreateProvider(); using (var initializer = CurrencyInfo.CreateInitializer()) { Aud = init(CurrencyIsoCode.AUD, initializer.Get); CurrencyCache.Add(Aud); Cad = init(CurrencyIsoCode.CAD, initializer.Get); CurrencyCache.Add(Cad); Chf = init(CurrencyIsoCode.CHF, initializer.Get); CurrencyCache.Add(Chf); Cny = init(CurrencyIsoCode.CNY, initializer.Get); CurrencyCache.Add(Cny); Dkk = init(CurrencyIsoCode.DKK, initializer.Get); CurrencyCache.Add(Dkk); Eur = init(CurrencyIsoCode.EUR, initializer.Get); CurrencyCache.Add(Eur); Gbp = init(CurrencyIsoCode.GBP, initializer.Get); CurrencyCache.Add(Gbp); Hkd = init(CurrencyIsoCode.HKD, initializer.Get); CurrencyCache.Add(Hkd); Huf = init(CurrencyIsoCode.HUF, initializer.Get); CurrencyCache.Add(Huf); Inr = init(CurrencyIsoCode.INR, initializer.Get); CurrencyCache.Add(Inr); Jpy = init(CurrencyIsoCode.JPY, initializer.Get); CurrencyCache.Add(Jpy); Mxn = init(CurrencyIsoCode.MXN, initializer.Get); CurrencyCache.Add(Mxn); Myr = init(CurrencyIsoCode.MYR, initializer.Get); CurrencyCache.Add(Myr); Nok = init(CurrencyIsoCode.NOK, initializer.Get); CurrencyCache.Add(Nok); Nzd = init(CurrencyIsoCode.NZD, initializer.Get); CurrencyCache.Add(Nzd); Rub = init(CurrencyIsoCode.RUB, initializer.Get); CurrencyCache.Add(Rub); Sek = init(CurrencyIsoCode.SEK, initializer.Get); CurrencyCache.Add(Sek); Sgd = init(CurrencyIsoCode.SGD, initializer.Get); CurrencyCache.Add(Sgd); Thb = init(CurrencyIsoCode.THB, initializer.Get); CurrencyCache.Add(Thb); Usd = init(CurrencyIsoCode.USD, initializer.Get); CurrencyCache.Add(Usd); Zar = init(CurrencyIsoCode.ZAR, initializer.Get); CurrencyCache.Add(Zar); Xxx = init(CurrencyIsoCode.XXX, initializer.Get); CurrencyCache.Add(Xxx); Xts = init(CurrencyIsoCode.XTS, initializer.Get); CurrencyCache.Add(Xts); } Euro = Eur; Dollar = Usd; Pound = Gbp; None = Xxx; Test = Xts; }