Table of Contents

EcbRateProviderOptions Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.Ecb.dll
Package
Bodu.Financial.ExchangeRates.Ecb 1.3.0
Source
EcbRateProviderOptions.cs

Configures how the EcbRateProvider downloads, caches, and interprets ECB euro reference-rate data.

public sealed class EcbRateProviderOptions : WebRateProviderOptions
Inheritance
EcbRateProviderOptions
Inherited Members
Extension Methods

Remarks

This type derives from WebRateProviderOptions, which supplies the endpoint base address, the HTTP contract (timeout, user agent and response-size cap), the synchronous-access, look-back and refresh behavior, the advertised history, the currency-alias map, and the per-concern log levels. The constructor points BaseAddress at the ECB's eurofxref statistics path and identifies the requests with a Bodu user agent. The members declared here are ECB-specific: the Feeds catalog and the on-disk cache settings.

The absolute URL of a feed is its FileName resolved against BaseAddress. An on-demand load reads the feed that covers the whole DefaultLookback window ending on the requested date: the narrowest feed whose look-back reaches the window's first day. The inherited RefreshInterval governs both the in-memory feeds and the on-disk cache: every ECB feed extends to the most recent business day, so a cached feed older than the interval is downloaded again, and in memory a loaded feed serves for good a request that ends before the day it was downloaded, or on a day it returned rates for, while a request that reaches a later day downloads the feed again once the interval has passed.

The ECB publishes ISO 4217 codes, so CurrencyAliases is empty by default; a currency label in a feed that is found among its keys is replaced by its value while the feed is read. The provider advertises the depth of its Feeds catalog while HistoryAvailability is left at Unbounded, and any other value set there in its place. Every member carries a working default, so the options bind cleanly through Microsoft.Extensions.Options; the dependency-injection registration binds this type from configuration and a configure delegate.

Constructors

EcbRateProviderOptions()

Initializes a new instance of the EcbRateProviderOptions class with the ECB eurofxref statistics path as its base address and a Bodu user agent.

public EcbRateProviderOptions()

Properties

CacheDirectory

Gets or sets the directory used by the on-disk cache.

public string? CacheDirectory { get; set; }

Property Value

string

The cache directory, or null to use a bodu-ecb folder under the system temporary path.

EnableDiskCache

Gets or sets a value indicating whether downloaded feed files are persisted to an on-disk cache.

public bool EnableDiskCache { get; set; }

Property Value

bool

true to enable the on-disk cache; otherwise false. Defaults to true.

Feeds

Gets or sets the catalog of feeds to draw from, ordered from the narrowest look-back to the widest.

public IReadOnlyList<EcbRateFeed> Feeds { get; set; }

Property Value

IReadOnlyList<EcbRateFeed>

The feed catalog; defaults to Default.

Methods

TryValidateCore(out string?)

Validates the ECB-specific options, ensuring the feed catalog is not empty.

protected override bool TryValidateCore(out string? error)

Parameters

error string

When this method returns false, a message describing the violated invariant; otherwise null.

Returns

bool

true when every ECB-specific invariant holds; otherwise false.

Applies to

ProductVersions
.NET8, 10