CurrencyRegistry Class
Definition
- Namespace
- Bodu.Financial.Currencies
- Assembly
- Bodu.Financial.dll
- Package
- Bodu.Financial 1.0.0
- Source
- CurrencyRegistry.cs
Read-only catalogue of CurrencyInfo entries keyed by ISO 4217 alphabetic code. Supports lookup by code and enumeration of every shipped currency.
public static class CurrencyRegistry
- Inheritance
-
CurrencyRegistry
- Inherited Members
Remarks
The catalogue is populated from the source-generated Bodu.Financial.Currencies.GeneratedCurrencyRegistration list at first access - no runtime reflection scans the assembly. It covers the full active and historic ISO 4217 set; every entry has a corresponding CurrencyCode member.
Lookups are thread-safe because the backing FrozenDictionary<TKey, TValue> is immutable.
Properties
All
Gets every shipped currency.
public static IReadOnlyCollection<CurrencyInfo> All { get; }
Property Value
- IReadOnlyCollection<CurrencyInfo>
A read-only enumeration of the registered CurrencyInfo entries.
Methods
Contains(string)
Determines whether the registry contains an entry for isoCode.
public static bool Contains(string isoCode)
Parameters
isoCodestringThe ISO 4217 alphabetic code to test.
Returns
Get(string)
Returns the CurrencyInfo for isoCode or throws when no entry exists.
public static CurrencyInfo Get(string isoCode)
Parameters
isoCodestringThe ISO 4217 alphabetic code to resolve.
Returns
- CurrencyInfo
The matching CurrencyInfo.
Remarks
Resolution is case-sensitive and matches canonical uppercase ISO 4217 codes only; a lower- or mixed-case code is treated as unknown and throws KeyNotFoundException.
Exceptions
- ArgumentNullException
isoCodeis null.- KeyNotFoundException
No currency is registered under
isoCode.
TryGet(string, out CurrencyInfo?)
Attempts to look up the currency identified by isoCode.
public static bool TryGet(string isoCode, out CurrencyInfo? info)
Parameters
isoCodestringThe ISO 4217 alphabetic code to resolve.
infoCurrencyInfoWhen this method returns true, the matching CurrencyInfo; otherwise the default value.
Returns
Remarks
Lookup is case-sensitive and matches canonical uppercase ISO 4217 codes only; a lower- or mixed-case code is treated as unknown and returns false. This mirrors the uppercase-only ISO-code contract the exchange-rate providers enforce (a mixed-case code is rejected as malformed there), keeping code resolution uniform across the library.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |