BoeFinancialServiceBuilderExtensions Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates
- Assembly
- Bodu.Financial.ExchangeRates.Boe.dll
- Package
- Bodu.Financial.ExchangeRates.Boe 0.7.1
Provides the fluent registration of the Bank of England exchange-rate provider onto an IFinancialServiceBuilder.
public static class BoeFinancialServiceBuilderExtensions
- Inheritance
-
BoeFinancialServiceBuilderExtensions
- Inherited Members
Fields
HttpClientName
The name of the HttpClient configured for Bank of England downloads.
public const string HttpClientName = "Bodu.Financial.ExchangeRates.Boe"
Field Value
Methods
AddBoeExchangeRates(IFinancialServiceBuilder, IConfiguration?, string, Action<BoeRateProviderOptions>?, Action<HttpStandardResilienceOptions>?)
Registers the Bank of England exchange-rate provider, binding its options and configuring a named HttpClient for downloads.
public static IFinancialServiceBuilder AddBoeExchangeRates(this IFinancialServiceBuilder builder, IConfiguration? configuration = null, string sectionName = "Financial:Boe", Action<BoeRateProviderOptions>? 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 BoeRateProviderOptions.sectionNamestringThe configuration section name. Defaults to
Financial:Boe.configureAction<BoeRateProviderOptions>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 loaded ranges 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. The handler sits in the message-handler pipeline
below the provider's single-flight load coordinator, so a retry re-issues the one in-flight request rather than
multiplying across coalesced callers. 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(builder => builder
.AddBoeExchangeRates(configuration, configure: opts => opts.Endpoint.HttpTimeout = TimeSpan.FromSeconds(15)));
Exceptions
- ArgumentNullException
Thrown when
builderis null.- ArgumentException
Thrown when
sectionNameis empty or white space.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |