Table of Contents

FixerFinancialServiceBuilderExtensions Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.Fixer.dll
Package
Bodu.Financial.ExchangeRates.Fixer 0.7.1
Source
FixerFinancialServiceBuilderExtensions.cs

Provides the fluent registration of the Fixer exchange-rate provider onto an IFinancialServiceBuilder.

public static class FixerFinancialServiceBuilderExtensions
Inheritance
FixerFinancialServiceBuilderExtensions
Inherited Members

Fields

HttpClientName

The name of the HttpClient configured for Fixer requests.

public const string HttpClientName = "Bodu.Financial.ExchangeRates.Fixer"

Field Value

string

Methods

AddFixerExchangeRates(IFinancialServiceBuilder, IConfiguration?, string, Action<FixerRateProviderOptions>?, Action<HttpStandardResilienceOptions>?)

Registers the Fixer exchange-rate provider, binding its options and configuring a named HttpClient for its requests.

public static IFinancialServiceBuilder AddFixerExchangeRates(this IFinancialServiceBuilder builder, IConfiguration? configuration = null, string sectionName = "Financial:Fixer", Action<FixerRateProviderOptions>? configure = null, Action<HttpStandardResilienceOptions>? configureResilience = null)

Parameters

builder IFinancialServiceBuilder

The financial service builder.

configuration IConfiguration

An optional configuration root or section. When supplied, the section named sectionName is bound into FixerRateProviderOptions.

sectionName string

The configuration section name. Defaults to Financial:Fixer.

configure Action<FixerRateProviderOptions>

An optional callback applied after configuration binding.

configureResilience Action<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)
    .AddFixerExchangeRates(
        configuration,
        configure: options => options.ApiKey = "…");

Exceptions

ArgumentNullException

Thrown when builder is null.

ArgumentException

Thrown when sectionName is empty or white space.

Applies to

ProductVersions
.NET8, 10