ImfFinancialServiceBuilderExtensions Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates
- Assembly
- Bodu.Financial.ExchangeRates.Imf.dll
- Package
- Bodu.Financial.ExchangeRates.Imf 0.7.1
Provides the fluent registration of the IMF exchange-rate provider onto an IFinancialServiceBuilder.
public static class ImfFinancialServiceBuilderExtensions
- Inheritance
-
ImfFinancialServiceBuilderExtensions
- Inherited Members
Fields
HttpClientName
The name of the HttpClient configured for IMF requests.
public const string HttpClientName = "Bodu.Financial.ExchangeRates.Imf"
Field Value
Methods
AddImfExchangeRates(IFinancialServiceBuilder, IConfiguration?, string, Action<ImfRateProviderOptions>?, Action<HttpStandardResilienceOptions>?)
Registers the IMF exchange-rate provider, binding its options and configuring a named HttpClient for its requests.
public static IFinancialServiceBuilder AddImfExchangeRates(this IFinancialServiceBuilder builder, IConfiguration? configuration = null, string sectionName = "Financial:Imf", Action<ImfRateProviderOptions>? configure = null, Action<HttpStandardResilienceOptions>? configureResilience = null)
Parameters
builderIFinancialServiceBuilderThe financial service builder.
configurationIConfigurationAn optional configuration root or section. When supplied, the section named
sectionNameis bound into ImfRateProviderOptions.sectionNamestringThe configuration section name. Defaults to
Financial:Imf.configureAction<ImfRateProviderOptions>An optional callback applied after configuration binding.
configureResilienceAction<HttpStandardResilienceOptions>An optional callback applied to the standard HTTP resilience options after the provider defaults have been set, allowing the retry, timeout, and circuit-breaker behavior to be tuned or effectively disabled.
Returns
- IFinancialServiceBuilder
The builder, for chaining.
Remarks
The provider is registered as a singleton so its in-memory store of fetched pairs is shared across resolutions; it is backed by an IHttpClientFactory client so handler lifetime is managed by the factory. The provider is also exposed as IDatedRateProvider and IRateProvider through idempotent registrations.
The named HttpClient is fitted with the standard Polly resilience handler (retry with exponential
backoff and jitter, a per-attempt timeout, a total-request timeout, and a circuit breaker), enabled by default
and tunable through configureResilience. Because the resilience handler enforces its own
per-attempt timeout driven from HttpTimeout, the
Timeout is set to InfiniteTimeSpan so the two timeout
mechanisms do not compete.
IServiceCollection services = new ServiceCollection();
services
.AddFinancialService(configuration)
.AddImfExchangeRates(configuration);
Exceptions
- ArgumentNullException
Thrown when
builderis null.- ArgumentException
Thrown when
sectionNameis empty or white space.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |