RbaRateProviderOptions Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates
- Assembly
- Bodu.Financial.ExchangeRates.Rba.dll
- Package
- Bodu.Financial.ExchangeRates.Rba 0.7.1
Configures how the RbaRateProvider downloads, caches, and interprets RBA exchange-rate data.
public sealed class RbaRateProviderOptions
- Inheritance
-
RbaRateProviderOptions
- 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
RbaRateProviderOptions()
public RbaRateProviderOptions()
Properties
AllowSynchronousNetworkAccess
Gets or sets a value indicating whether a synchronous lookup may block to download a missing era 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.
BaseUrl
Gets or sets the base URL under which the RBA publishes its historical exchange-rate files. Should end with a trailing slash so era file names resolve as relative paths.
public Uri BaseUrl { get; set; }
Property Value
- Uri
The base URL; defaults to the RBA historical statistics path.
CacheDirectory
Gets or sets the directory used by the on-disk cache.
public string? CacheDirectory { get; set; }
Property Value
CurrencyAliases
Gets or sets the map from RBA units labels to ISO 4217 codes, applied while resolving a column's currency.
public IDictionary<string, string> CurrencyAliases { get; set; }
Property Value
- IDictionary<string, string>
The alias map; defaults to mapping
SDRto the ISO codeXDR.
CurrentEraRefreshInterval
Gets or sets how long a cached copy of the open-ended current era remains fresh before it is re-downloaded.
public TimeSpan CurrentEraRefreshInterval { get; set; }
Property Value
- TimeSpan
The refresh interval; defaults to 12 hours. Immutable historical eras are cached indefinitely.
DownloadCompletedLogLevel
Gets or sets the level at which a completed era 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 era download is logged.
public LogLevel DownloadFailedLogLevel { get; set; }
Property Value
DownloadStartingLogLevel
Gets or sets the level at which the start of an era download is logged.
public LogLevel DownloadStartingLogLevel { get; set; }
Property Value
EnableDiskCache
Gets or sets a value indicating whether downloaded era files are persisted to an on-disk cache.
public bool EnableDiskCache { get; set; }
Property Value
Eras
Gets or sets the catalogue of era files to draw from.
public IReadOnlyList<RbaEraWorkbook> Eras { get; set; }
Property Value
- IReadOnlyList<RbaEraWorkbook>
The era catalogue; defaults to Default.
HttpTimeout
Gets or sets the HTTP request timeout applied to era downloads by the dependency-injection registration.
public TimeSpan HttpTimeout { get; set; }
Property Value
- TimeSpan
The HTTP timeout; defaults to 30 seconds.
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.
UserAgent
Gets or sets the User-Agent header applied to era downloads by the dependency-injection registration.
public string UserAgent { get; set; }
Property Value
- string
The user-agent string; defaults to a Bodu identifier.
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
errorstringWhen this method returns false, a message describing the first violated invariant; otherwise null.
Returns
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 BaseUrl is null; Eras is null or empty; HttpTimeout or CurrentEraRefreshInterval is not greater than zero; CurrencyAliases is null; or any
*LogLevelis not a defined LogLevel.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |