DatedRateProviderAdapter Class
Definition
Adapts an IDatedRateProvider to the simpler timeless IRateProvider surface by pinning a fixed valuation date and lookup options.
public sealed class DatedRateProviderAdapter : IRateProvider
- Inheritance
-
DatedRateProviderAdapter
- Implements
- Inherited Members
- Extension Methods
Remarks
Use this adapter when an existing consumer already accepts IRateProvider but the rates should nevertheless come from a date-aware source - for example, a fixed reporting-period end-date used to convert many amounts consistently throughout a single accounting workflow.
Constructors
DatedRateProviderAdapter(IDatedRateProvider, DateOnly, RateLookupOptions?)
Initializes a new instance of the DatedRateProviderAdapter class.
public DatedRateProviderAdapter(IDatedRateProvider inner, DateOnly date, RateLookupOptions? options = null)
Parameters
innerIDatedRateProviderThe underlying dated provider to delegate to.
dateDateOnlyThe valuation date pinned to every lookup.
optionsRateLookupOptionsThe lookup options pinned to every lookup. null is treated as Exact.
Exceptions
- ArgumentNullException
Thrown if
inneris null.- ArgumentOutOfRangeException
Thrown if
optionscontains an undefined enum value or a negative tolerance.- ArgumentException
Thrown if
optionsspecifies Exact with a non-zero tolerance.
Methods
GetRate(string, string)
Returns the exchange rate that converts one unit of fromIsoCode to units of
toIsoCode.
public decimal GetRate(string fromIsoCode, string toIsoCode)
Parameters
fromIsoCodestringThe source currency's ISO 4217 code.
toIsoCodestringThe destination currency's ISO 4217 code.
Returns
- decimal
The rate.
Exceptions
- KeyNotFoundException
No rate is available for the requested pair.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |