Table of Contents

ImfRateProviderOptions Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.Imf.dll
Package
Bodu.Financial.ExchangeRates.Imf 0.7.1
Source
ImfRateProviderOptions.cs

Configures how the ImfRateProvider addresses, caches, and interprets the IMF Representative Exchange Rates monthly report.

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

Remarks

This type derives from WebRateProviderOptions, which supplies the endpoint base address, the HTTP contract, the synchronous-access and look-back behaviour, and the per-concern log levels. The members declared here are report-specific: the ReportPath and ReportType that address the monthly report, the on-disk cache settings, and the CurrencyNames map that resolves an IMF currency label to its ISO 4217 code. The report is keyless, so no API key is required.

USD-anchored, bulk. The report quotes every reported currency against the US dollar for each business day of the month, so a single download warms the store for all currencies and all business days at once. Only USD/X and X/USD pairs are serviceable; the reverse direction is served by the base inverse-lookup fallback. Every member carries a working default, so the options bind cleanly through Microsoft.Extensions.Options.

Constructors

ImfRateProviderOptions()

Initializes a new instance of the ImfRateProviderOptions class with the IMF report host as its base address, an unbounded history depth, and the default currency-name map.

public ImfRateProviderOptions()

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-imf folder under the system temporary path.

CurrencyNames

Gets or sets the map from an IMF currency label (footnote-stripped and trimmed) to its ISO 4217 code, applied while normalizing a report row.

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

Property Value

IDictionary<string, string>

The currency-name map; seeded in the constructor with the currencies the report commonly quotes.

Remarks

A label absent from this map is resolved directly against the ISO 4217 catalogue, and a label that resolves neither way is skipped. Extend the map to add labels the IMF publishes that are not seeded here.

EnableDiskCache

Gets or sets a value indicating whether downloaded report 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.

RefreshInterval

Gets or sets how long a cached copy of the current month's report remains fresh before it is re-downloaded.

public TimeSpan RefreshInterval { get; set; }

Property Value

TimeSpan

The refresh interval; defaults to 12 hours.

Remarks

A closed month's report is immutable and is served from cache regardless of age; only the current, still-growing month is subject to this interval.

ReportPath

Gets or sets the relative report resource path appended to the base address.

public string ReportPath { get; set; }

Property Value

string

The report path; defaults to rms_mth.aspx.

ReportType

Gets or sets the report-type selector supplied to the endpoint.

public string ReportType { get; set; }

Property Value

string

The report type; defaults to REP (representative rates).

Methods

TryValidateCore(out string?)

Validates the report-specific options, ensuring the report path, report type, and currency-name map are usable.

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 report-specific invariant holds; otherwise false.

Applies to

ProductVersions
.NET8, 10