Table of Contents

EcbRateProviderOptions Class

Definition

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

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

public sealed class EcbRateProviderOptions
Inheritance
EcbRateProviderOptions
Inherited Members
Extension Methods

Remarks

Every member carries a working default, so the options bind cleanly through Microsoft.Extensions.Options and require no configuration for the common case. The dependency-injection package binds this type from configuration and a configure delegate.

The *LogLevel members set the LogLevel at which each diagnostic the provider emits is logged, so consumers can re-tune verbosity per concern without category-wide log filters. Set any of them to None to suppress that event entirely.

Constructors

EcbRateProviderOptions()

public EcbRateProviderOptions()

Properties

AllowSynchronousNetworkAccess

Gets or sets a value indicating whether a synchronous lookup may block to download a missing feed on demand.

public bool AllowSynchronousNetworkAccess { get; set; }

Property Value

bool

true to allow synchronous, blocking downloads from IDatedRateProvider lookups; false to serve only already-loaded data. Defaults to false, so the provider serves a snapshot of already-loaded data and a synchronous miss does not reach the network.

Remarks

Blocking on network I/O from a synchronous method can deadlock in environments with a single-threaded synchronization context (classic ASP.NET, WPF, WinForms), so the default is snapshot-only. Leave this false and warm the store with PreloadAsync(CancellationToken) or LoadRangeAsync(DateOnly, DateOnly, CancellationToken) at startup; set it to true only to opt in to a blocking on-demand fetch from the synchronous lookup path.

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.

CurrencyAliases

Gets or sets the map from ECB currency labels to ISO 4217 codes, applied while normalizing a quoted currency.

public IDictionary<string, string> CurrencyAliases { get; set; }

Property Value

IDictionary<string, string>

The alias map; defaults to an empty map because the ECB publishes ISO 4217 codes directly.

DownloadCompletedLogLevel

Gets or sets the level at which a completed feed download (with its observation count) is logged.

public LogLevel DownloadCompletedLogLevel { get; set; }

Property Value

LogLevel

The log level; defaults to Information.

DownloadFailedLogLevel

Gets or sets the level at which a failed feed download is logged.

public LogLevel DownloadFailedLogLevel { get; set; }

Property Value

LogLevel

The log level; defaults to Warning.

DownloadStartingLogLevel

Gets or sets the level at which the start of a feed download is logged.

public LogLevel DownloadStartingLogLevel { get; set; }

Property Value

LogLevel

The log level; defaults to Debug.

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.

Endpoint

Gets or sets the endpoint options describing the provider's connection to the ECB eurofxref endpoints - the base URL, transport timeout, and request identity.

public EcbEndpointOptions Endpoint { get; set; }

Property Value

EcbEndpointOptions

The endpoint options; defaults to a new EcbEndpointOptions targeting the ECB.

Feeds

Gets or sets the catalogue 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 catalogue; defaults to Default.

ObservationIngestedLogLevel

Gets or sets the level at which each individual ingested rate observation is logged.

public LogLevel ObservationIngestedLogLevel { get; set; }

Property Value

LogLevel

The log level; defaults to Information.

RefreshInterval

Gets or sets how long a cached copy of a feed remains fresh before it is re-downloaded.

public TimeSpan RefreshInterval { get; set; }

Property Value

TimeSpan

The refresh interval; defaults to 12 hours.

Remarks

Every ECB feed extends to the most recent business day, so all feeds are treated as refreshable rather than immutable: a cached feed older than this interval is re-downloaded on the next load.

SynchronousNetworkFetchLogLevel

Gets or sets the level at which a synchronous, blocking on-demand network fetch is logged.

public LogLevel SynchronousNetworkFetchLogLevel { get; set; }

Property Value

LogLevel

The log level; defaults to Warning.

Methods

TryValidate(out string?)

Attempts to validate the options without throwing, reporting the first invariant that is violated.

public bool TryValidate(out string? error)

Parameters

error string

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

Returns

bool

true when every invariant holds; otherwise false.

Remarks

The throwing Validate() method is expressed in terms of this method, and the dependency-injection registration wires it into ValidateOnStart so misconfiguration fails fast at application startup.

Validate()

Validates the options, throwing when a required value is missing or an invariant is violated.

public void Validate()

Exceptions

ArgumentException

Thrown when Endpoint is null or fails validation; Feeds is null or empty; RefreshInterval is not greater than zero; CurrencyAliases is null; or any *LogLevel is not a defined LogLevel.

Applies to

ProductVersions
.NET8, 10