MoneyOfTCurrencyExchangeRateExtensions Class
Definition
Provides extension methods that resolve a dated exchange rate from an IDatedRateProvider and apply it to a Money<TCurrency> value.
public static class MoneyOfTCurrencyExchangeRateExtensions
- Inheritance
-
MoneyOfTCurrencyExchangeRateExtensions
- Inherited Members
Methods
ConvertToWithRate<TSource, TTarget>(Money<TSource>, IDatedRateProvider, DateOnly, RateLookupOptions?, MidpointRounding)
Converts amount to TTarget and additionally returns the full
RateLookupResult used so callers can audit the selected rate.
public static MoneyConversionResult<TSource, TTarget> ConvertToWithRate<TSource, TTarget>(this Money<TSource> amount, IDatedRateProvider provider, DateOnly date, RateLookupOptions? options = null, MidpointRounding rounding = MidpointRounding.ToEven) where TSource : ICurrency where TTarget : ICurrency
Parameters
amountMoney<TSource>The amount to convert.
providerIDatedRateProviderThe dated provider that resolves the exchange rate.
dateDateOnlyThe valuation date.
optionsRateLookupOptionsThe lookup rules to apply.
roundingMidpointRoundingThe rounding mode applied to the converted amount. Defaults to ToEven.
Returns
- MoneyConversionResult<TSource, TTarget>
A MoneyConversionResult<TSource, TTarget> containing the source, target, and rate metadata.
Type Parameters
TSourceThe source currency.
TTargetThe destination currency.
Exceptions
- ArgumentNullException
Thrown if
provideris null.- KeyNotFoundException
Thrown if no rate is available for the requested pair under the supplied options.
ConvertTo<TSource, TTarget>(Money<TSource>, IDatedRateProvider, DateOnly, RateLookupOptions?, MidpointRounding)
Converts amount to TTarget using the rate resolved by
provider for date under options.
public static Money<TTarget> ConvertTo<TSource, TTarget>(this Money<TSource> amount, IDatedRateProvider provider, DateOnly date, RateLookupOptions? options = null, MidpointRounding rounding = MidpointRounding.ToEven) where TSource : ICurrency where TTarget : ICurrency
Parameters
amountMoney<TSource>The amount to convert.
providerIDatedRateProviderThe dated provider that resolves the exchange rate.
dateDateOnlyThe valuation date.
optionsRateLookupOptionsThe lookup rules to apply.
roundingMidpointRoundingThe rounding mode applied to the converted amount. Defaults to ToEven.
Returns
- Money<TTarget>
The converted amount as a Money<TCurrency>.
Type Parameters
TSourceThe source currency.
TTargetThe destination currency.
Exceptions
- ArgumentNullException
Thrown if
provideris null.- KeyNotFoundException
Thrown if no rate is available for the requested pair under the supplied options.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |