Table of Contents

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

isoCode string

The ISO 4217 alphabetic code to test.

Returns

bool

true when an entry exists; otherwise false.

Get(string)

Returns the CurrencyInfo for isoCode or throws when no entry exists.

public static CurrencyInfo Get(string isoCode)

Parameters

isoCode string

The 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

isoCode is 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

isoCode string

The ISO 4217 alphabetic code to resolve.

info CurrencyInfo

When this method returns true, the matching CurrencyInfo; otherwise the default value.

Returns

bool

true when the currency is registered; otherwise false.

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

ProductVersions
.NET8, 10