Table of Contents

ExchangeRateHostServiceCollectionExtensions Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.ExchangeRateHost.dll
Package
Bodu.Financial.ExchangeRates.ExchangeRateHost 0.7.1
Source
ExchangeRateHostServiceCollectionExtensions.cs

Provides a one-call entry point that registers the core Bodu.Financial services together with the exchangerate.host exchange-rate provider.

public static class ExchangeRateHostServiceCollectionExtensions
Inheritance
ExchangeRateHostServiceCollectionExtensions
Inherited Members

Methods

AddExchangeRateHostExchangeRates(IServiceCollection, IConfiguration?, string, Action<ExchangeRateHostRateProviderOptions>?)

Registers the core Bodu.Financial services and the exchangerate.host exchange-rate provider.

public static IFinancialServiceBuilder AddExchangeRateHostExchangeRates(this IServiceCollection services, IConfiguration? configuration = null, string sectionName = "Financial:ExchangeRateHost", Action<ExchangeRateHostRateProviderOptions>? 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 ExchangeRateHostRateProviderOptions from sectionName.

sectionName string

The exchangerate.host configuration section name. Defaults to Financial:ExchangeRateHost.

configure Action<ExchangeRateHostRateProviderOptions>

An optional callback applied after exchangerate.host configuration binding.

Returns

IFinancialServiceBuilder

An IFinancialServiceBuilder for further composition.

Examples

IServiceCollection services = new ServiceCollection();

services.AddExchangeRateHostExchangeRates(configuration, configure: options => options.ApiKey = "…");

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