/// <summary> /// Initialize a new CurrencyCollection with the given currencies. /// These will be registered as a singleton as well as returned directly /// </summary> /// <param name="currencies">The currencies to register</param> /// <returns>The created Currency Collection</returns> public static IReadOnlyCollection <Currency> Initialize(params Currency[] currencies) { var instance = new CurrencyCollection(); instance.AddRange(currencies); SetProvider(() => instance); return(instance); }
/// <summary> /// Set the provider to use the region info's from standard .Net /// </summary> public static IReadOnlyCollection <Currency> SetRegionInfoProvider() { var currencies = CultureInfo .GetCultures(CultureTypes.AllCultures) .Where(culture => !culture.IsNeutralCulture) .Where(culture => culture.LCID != CultureInfo.InvariantCulture.LCID) .Select(culture => new RegionInfo(culture.LCID)) .Select(region => new Currency(region.ISOCurrencySymbol, region.CurrencySymbol)) .Distinct() .ToArray(); var instance = new CurrencyCollection(); instance.AddRange(currencies); SetProvider(() => instance); return(instance); }