CurrencyLookupService Class
Definition
- Namespace
- Bodu.Financial.Currencies
- Assembly
- Bodu.Financial.dll
- Package
- Bodu.Financial 1.3.0
- Source
- CurrencyLookupService.cs
Default ICurrencyLookup backed by CurrencyRegistry. Reverse indexes for numeric code, symbol, and region are built lazily from the registry on first use.
public sealed class CurrencyLookupService : ICurrencyLookup
- Inheritance
-
CurrencyLookupService
- Implements
- Inherited Members
- Extension Methods
Remarks
The registry is a closed catalog with no registration seam, so the indexes never change after they are built. On a numeric-code collision, the active currency wins over a historic one.
The shipped catalog carries no symbol or region data, so TryBySymbol(string, out IReadOnlyList<CurrencyInfo>) and TryByRegion(string, out IReadOnlyList<CurrencyInfo>) resolve nothing with this lookup. Implement ICurrencyLookup over CurrencyInfo records that carry that data when symbol or region resolution is needed, for example for CultureAware parsing.
Constructors
CurrencyLookupService()
Initializes a new instance of the CurrencyLookupService class.
public CurrencyLookupService()
Methods
ByCulture(CultureInfo)
Resolves the currencies associated with culture's region.
public IReadOnlyList<CurrencyInfo> ByCulture(CultureInfo culture)
Parameters
cultureCultureInfoThe culture whose region currency is resolved.
Returns
- IReadOnlyList<CurrencyInfo>
The matching currencies, or an empty list when none are found.
TryByCurrencyCode(CurrencyCode, out CurrencyInfo)
Attempts to resolve a currency by its CurrencyCode enum value.
public bool TryByCurrencyCode(CurrencyCode code, out CurrencyInfo currency)
Parameters
codeCurrencyCodeThe active ISO 4217 currency code.
currencyCurrencyInfoWhen this method returns true, the matching currency.
Returns
TryByIsoCode(string, out CurrencyInfo)
Attempts to resolve a currency by its ISO 4217 alphabetic code.
public bool TryByIsoCode(string isoCode, out CurrencyInfo currency)
Parameters
isoCodestringThe three-letter uppercase ISO code.
currencyCurrencyInfoWhen this method returns true, the matching currency.
Returns
TryByNumericCode(int, out CurrencyInfo)
Attempts to resolve a currency by its ISO 4217 numeric code.
public bool TryByNumericCode(int numericCode, out CurrencyInfo currency)
Parameters
numericCodeintThe three-digit numeric code.
currencyCurrencyInfoWhen this method returns true, the matching currency.
Returns
TryByRegion(string, out IReadOnlyList<CurrencyInfo>)
Attempts to resolve the currencies used in the region identified by regionCode.
public bool TryByRegion(string regionCode, out IReadOnlyList<CurrencyInfo> matches)
Parameters
regionCodestringThe ISO 3166 region code.
matchesIReadOnlyList<CurrencyInfo>When this method returns true, the matching currencies.
Returns
TryBySymbol(string, out IReadOnlyList<CurrencyInfo>)
Attempts to resolve the currencies that use symbol as a primary or alternative symbol.
public bool TryBySymbol(string symbol, out IReadOnlyList<CurrencyInfo> matches)
Parameters
symbolstringThe currency symbol.
matchesIReadOnlyList<CurrencyInfo>When this method returns true, the matching currencies.
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |