Table of Contents

EcbServiceCollectionExtensions Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.Ecb.dll
Package
Bodu.Financial.ExchangeRates.Ecb 0.7.1
Source
EcbServiceCollectionExtensions.cs

Provides a one-call entry point that registers the core Bodu.Financial services together with the ECB euro reference-rate provider.

public static class EcbServiceCollectionExtensions
Inheritance
EcbServiceCollectionExtensions
Inherited Members

Methods

AddEcbExchangeRates(IServiceCollection, IConfiguration?, string, Action<EcbRateProviderOptions>?)

Registers the core Bodu.Financial services and the ECB euro reference-rate provider.

public static IFinancialServiceBuilder AddEcbExchangeRates(this IServiceCollection services, IConfiguration? configuration = null, string sectionName = "Financial:Ecb", Action<EcbRateProviderOptions>? configure = null)

Parameters

services IServiceCollection

The service collection to register into.

configuration IConfiguration

An optional configuration root. When supplied, FinancialOptions is bound from the Financial section and EcbRateProviderOptions from sectionName.

sectionName string

The ECB configuration section name. Defaults to Financial:Ecb.

configure Action<EcbRateProviderOptions>

An optional callback applied after ECB configuration binding.

Returns

IFinancialServiceBuilder

An IFinancialServiceBuilder for further composition.

Remarks

IServiceCollection services = new ServiceCollection();

// One-call registration: core financial services plus the ECB provider.
services.AddEcbExchangeRates(configure: opts =>
{
    opts.EnableDiskCache = true;
});

using ServiceProvider provider = services.BuildServiceProvider();
var rates = provider.GetRequiredService<IDatedRateProvider>();

Exceptions

ArgumentNullException

Thrown when services is null.

ArgumentException

Thrown when sectionName is empty or white space.

Applies to

ProductVersions
.NET8, 10