Table of Contents

MoneyOfTCurrencyExchangeRateExtensions Class

Definition

Namespace
Bodu.Financial.Extensions
Assembly
Bodu.Financial.dll
Package
Bodu.Financial 1.0.0
Source
MoneyOfTCurrencyExchangeRateExtensions.ConvertTo.cs

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

amount Money<TSource>

The amount to convert.

provider IDatedRateProvider

The dated provider that resolves the exchange rate.

date DateOnly

The valuation date.

options RateLookupOptions

The lookup rules to apply.

rounding MidpointRounding

The 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

TSource

The source currency.

TTarget

The destination currency.

Exceptions

ArgumentNullException

Thrown if provider is 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

amount Money<TSource>

The amount to convert.

provider IDatedRateProvider

The dated provider that resolves the exchange rate.

date DateOnly

The valuation date.

options RateLookupOptions

The lookup rules to apply.

rounding MidpointRounding

The rounding mode applied to the converted amount. Defaults to ToEven.

Returns

Money<TTarget>

The converted amount as a Money<TCurrency>.

Type Parameters

TSource

The source currency.

TTarget

The destination currency.

Exceptions

ArgumentNullException

Thrown if provider is null.

KeyNotFoundException

Thrown if no rate is available for the requested pair under the supplied options.

Applies to

ProductVersions
.NET8, 10