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
IsoCodestringThe ISO 4217 three-letter alphabetic code.
MinorUnitsintThe number of fractional digits in the currency's minor unit.
CashRoundingIncrementdecimalThe smallest physical cash denomination in the major unit, or
0mwhen no special cash rounding is required beyondMinorUnits.IsHistoricboolWhether the currency has been demonetized.
DemonetizedOnDateOnly?The date the currency was withdrawn from circulation, when known.
SuccessorIsoCodestringThe ISO 4217 code of the currency that replaced this one, when defined.
EnglishNamestringThe currency's English-language name in singular Title Case (for example,
"United States Dollar"), or an empty string when no name is supplied.NumericCodeintThe ISO 4217 three-digit numeric code (for example,
840forUSD,36forAUD), or0when 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
DemonetizedOn
The date the currency was withdrawn from circulation, when known.
public DateOnly? DemonetizedOn { get; init; }
Property Value
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
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
IsHistoric
Whether the currency has been demonetized.
public bool IsHistoric { get; init; }
Property Value
IsoCode
The ISO 4217 three-letter alphabetic code.
public string IsoCode { get; init; }
Property Value
MinorUnits
The number of fractional digits in the currency's minor unit.
public int MinorUnits { get; init; }
Property Value
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
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
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
Equals(CurrencyInfo?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(CurrencyInfo? other)
Parameters
otherCurrencyInfoAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
FromCurrencyCode(CurrencyCode)
Resolves a CurrencyCode enum value to its registered CurrencyInfo.
public static CurrencyInfo FromCurrencyCode(CurrencyCode code)
Parameters
codeCurrencyCodeThe ISO 4217 currency code to resolve.
Returns
- CurrencyInfo
The registry entry corresponding to
code.
Exceptions
- ArgumentOutOfRangeException
codeis 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
isoCodestringThe 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
isoCodeis null.- ArgumentException
isoCodedoes 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
isoCodestringThe three-letter uppercase ISO code.
codeCurrencyCodeWhen this method returns true, the matching enum value.
Returns
Remarks
Operators
operator ==(CurrencyInfo?, CurrencyInfo?)
public static bool operator ==(CurrencyInfo? left, CurrencyInfo? right)
Parameters
leftCurrencyInforightCurrencyInfo
Returns
operator !=(CurrencyInfo?, CurrencyInfo?)
public static bool operator !=(CurrencyInfo? left, CurrencyInfo? right)
Parameters
leftCurrencyInforightCurrencyInfo
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |