Table of Contents

CurrencyInfo Class

Definition

Namespace
Bodu.Financial.Currencies
Assembly
Bodu.Financial.dll
Package
Bodu.Financial 1.0.0
Source
CurrencyInfo.cs

Carries the runtime metadata of a currency: ISO 4217 code, minor-unit precision, cash-rounding increment, and historicity / successor information.

public sealed record CurrencyInfo : IEquatable<CurrencyInfo>
Inheritance
CurrencyInfo
Implements
Inherited Members
Extension Methods

Remarks

This record is the runtime counterpart of an ICurrency tag type. The runtime-tagged Money and the MoneyBag aggregate operate against CurrencyRegistry entries of this shape so they can handle currencies the consumer learns about at runtime (for example, from a deserialised JSON payload).

Constructors

CurrencyInfo(string, int, decimal, bool, DateOnly?, string?, string, int)

Carries the runtime metadata of a currency: ISO 4217 code, minor-unit precision, cash-rounding increment, and historicity / successor information.

public CurrencyInfo(string IsoCode, int MinorUnits, decimal CashRoundingIncrement, bool IsHistoric, DateOnly? DemonetizedOn, string? SuccessorIsoCode, string EnglishName = "", int NumericCode = 0)

Parameters

IsoCode string

The ISO 4217 three-letter alphabetic code.

MinorUnits int

The number of fractional digits in the currency's minor unit.

CashRoundingIncrement decimal

The smallest physical cash denomination in the major unit, or 0m when no special cash rounding is required beyond MinorUnits.

IsHistoric bool

Whether the currency has been demonetized.

DemonetizedOn DateOnly?

The date the currency was withdrawn from circulation, when known.

SuccessorIsoCode string

The ISO 4217 code of the currency that replaced this one, when defined.

EnglishName string

The currency's English-language name in singular Title Case (for example, "United States Dollar"), or an empty string when no name is supplied.

NumericCode int

The ISO 4217 three-digit numeric code (for example, 840 for USD, 36 for AUD), or 0 when the currency is custom or the numeric code is unknown.

Remarks

This record is the runtime counterpart of an ICurrency tag type. The runtime-tagged Money and the MoneyBag aggregate operate against CurrencyRegistry entries of this shape so they can handle currencies the consumer learns about at runtime (for example, from a deserialised JSON payload).

Properties

AlternativeSymbols

Gets alternative symbols that may also denote the currency.

public IReadOnlyList<string> AlternativeSymbols { get; init; }

Property Value

IReadOnlyList<string>

The additional symbols recognised for the currency.

CashRoundingIncrement

The smallest physical cash denomination in the major unit, or 0m when no special cash rounding is required beyond MinorUnits.

public decimal CashRoundingIncrement { get; init; }

Property Value

decimal

DemonetizedOn

The date the currency was withdrawn from circulation, when known.

public DateOnly? DemonetizedOn { get; init; }

Property Value

DateOnly?

EnglishName

The currency's English-language name in singular Title Case (for example, "United States Dollar"), or an empty string when no name is supplied.

public string EnglishName { get; init; }

Property Value

string

InternationalSymbol

Gets the currency's internationally disambiguated symbol (for example, "US$" or "R$"), or an empty string when none is supplied.

public string InternationalSymbol { get; init; }

Property Value

string

The unambiguous symbol used where the bare Symbol would be ambiguous.

IsHistoric

Whether the currency has been demonetized.

public bool IsHistoric { get; init; }

Property Value

bool

IsoCode

The ISO 4217 three-letter alphabetic code.

public string IsoCode { get; init; }

Property Value

string

MinorUnits

The number of fractional digits in the currency's minor unit.

public int MinorUnits { get; init; }

Property Value

int

NativeName

Gets the currency's name in its primary native language, or an empty string when none is supplied.

public string NativeName { get; init; }

Property Value

string

The localized currency name.

NumericCode

The ISO 4217 three-digit numeric code (for example, 840 for USD, 36 for AUD), or 0 when the currency is custom or the numeric code is unknown.

public int NumericCode { get; init; }

Property Value

int

RegionCodes

Gets the ISO 3166 region codes in which the currency is used.

public IReadOnlyList<string> RegionCodes { get; init; }

Property Value

IReadOnlyList<string>

The regions associated with the currency.

SuccessorIsoCode

The ISO 4217 code of the currency that replaced this one, when defined.

public string? SuccessorIsoCode { get; init; }

Property Value

string

Symbol

Gets the currency's primary symbol (for example, "$" or "€"), or an empty string when none is supplied.

public string Symbol { get; init; }

Property Value

string

The display symbol associated with the currency.

Methods

Deconstruct(out string, out int, out decimal, out bool, out DateOnly?, out string?, out string, out int)

public void Deconstruct(out string IsoCode, out int MinorUnits, out decimal CashRoundingIncrement, out bool IsHistoric, out DateOnly? DemonetizedOn, out string? SuccessorIsoCode, out string EnglishName, out int NumericCode)

Parameters

IsoCode string
MinorUnits int
CashRoundingIncrement decimal
IsHistoric bool
DemonetizedOn DateOnly?
SuccessorIsoCode string
EnglishName string
NumericCode int

Equals(CurrencyInfo?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CurrencyInfo? other)

Parameters

other CurrencyInfo

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FromCurrencyCode(CurrencyCode)

Resolves a CurrencyCode enum value to its registered CurrencyInfo.

public static CurrencyInfo FromCurrencyCode(CurrencyCode code)

Parameters

code CurrencyCode

The ISO 4217 currency code to resolve.

Returns

CurrencyInfo

The registry entry corresponding to code.

Exceptions

ArgumentOutOfRangeException

code is None or is not a defined CurrencyCode member.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ParseCurrencyCode(string)

Resolves an ISO 4217 alphabetic code to the matching CurrencyCode enum member.

public static CurrencyCode ParseCurrencyCode(string isoCode)

Parameters

isoCode string

The three-letter uppercase ISO code.

Returns

CurrencyCode

The CurrencyCode member matching isoCode.

Remarks

The throwing counterpart of TryGetCurrencyCode(string, out CurrencyCode), and the canonical boundary helper for turning an externally supplied ISO string into the stored enum representation.

Exceptions

ArgumentNullException

isoCode is null.

ArgumentException

isoCode does not match any active or historic currency in CurrencyCode.

ToCurrencyCode()

Returns the CurrencyCode enum value corresponding to this CurrencyInfo.

public CurrencyCode ToCurrencyCode()

Returns

CurrencyCode

The matching enum member.

Exceptions

InvalidOperationException

The currency's IsoCode does not correspond to any CurrencyCode member (for example, a currency outside the shipped ISO 4217 catalogue).

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryGetCurrencyCode(string, out CurrencyCode)

Attempts to resolve an ISO 4217 alphabetic code to the matching CurrencyCode enum member.

public static bool TryGetCurrencyCode(string isoCode, out CurrencyCode code)

Parameters

isoCode string

The three-letter uppercase ISO code.

code CurrencyCode

When this method returns true, the matching enum value.

Returns

bool

true when isoCode matches a currency in the enum - active or historic; otherwise false.

Remarks

The match is case-sensitive: only the canonical three-uppercase-letter ISO form resolves successfully. The None sentinel and any code outside the shipped catalogue surface here as false.

Operators

operator ==(CurrencyInfo?, CurrencyInfo?)

public static bool operator ==(CurrencyInfo? left, CurrencyInfo? right)

Parameters

left CurrencyInfo
right CurrencyInfo

Returns

bool

operator !=(CurrencyInfo?, CurrencyInfo?)

public static bool operator !=(CurrencyInfo? left, CurrencyInfo? right)

Parameters

left CurrencyInfo
right CurrencyInfo

Returns

bool

Applies to

ProductVersions
.NET8, 10