Bodu.Financial.ExchangeRates.DependencyInjection
1.3.0
dotnet add package Bodu.Financial.ExchangeRates.DependencyInjection --version 1.3.0
NuGet\Install-Package Bodu.Financial.ExchangeRates.DependencyInjection -Version 1.3.0
<PackageReference Include="Bodu.Financial.ExchangeRates.DependencyInjection" Version="1.3.0" />
<PackageVersion Include="Bodu.Financial.ExchangeRates.DependencyInjection" Version="1.3.0" />
<PackageReference Include="Bodu.Financial.ExchangeRates.DependencyInjection" />
paket add Bodu.Financial.ExchangeRates.DependencyInjection --version 1.3.0
#r "nuget: Bodu.Financial.ExchangeRates.DependencyInjection, 1.3.0"
#:package Bodu.Financial.ExchangeRates.DependencyInjection@1.3.0
#addin nuget:?package=Bodu.Financial.ExchangeRates.DependencyInjection&version=1.3.0
#tool nuget:?package=Bodu.Financial.ExchangeRates.DependencyInjection&version=1.3.0
Bodu.Financial.ExchangeRates.DependencyInjection
API stability - Stable. The public API surface is committed: breaking changes are reserved for a major-version bump per SemVer, except a deliberate break that is recorded in the release notes and in the package's
CompatibilitySuppressions.xml. See versioning and support.
Shared dependency-injection machinery for the
Bodu.Financial web exchange-rate providers. Every per-source provider
package (Boe, Ecb, Rba, Yahoo, Ofx, Xe, Oanda, Fixer, ExchangeRateHost, Fred, Imf) delegates its own Add…
registration to the single generic extension defined here, so named-HttpClient
configuration, resilience, options binding, and provider lifetime are wired one way across
the whole family.
AddWebRateProvider
AddWebRateProvider<TProvider, TOptions> registers a WebRateProvider
subclass as a singleton, exposed as both IDatedRateProvider and
IRateProvider. It:
- binds and validates
TOptionsthroughMicrosoft.Extensions.Options; - configures a named
HttpClientfor the provider from the options (user agent, HTTP timeout) viaIHttpClientFactory, so the provider never owns the client lifetime; - layers Polly standard resilience over that client, with the attempt / total-request / circuit-breaker windows aligned to the configured timeout; and
- constructs the provider from the resolved client, options, and logger.
A provider package's public Add… method is a thin call through to this:
using Bodu.Financial;
using Bodu.Financial.ExchangeRates;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Http.Resilience;
using Microsoft.Extensions.Logging;
// Inside a provider package's own extension:
public static IFinancialServiceBuilder AddAcmeExchangeRates(
this IFinancialServiceBuilder builder,
IConfiguration? configuration = null,
string sectionName = "Financial:Acme",
Action<AcmeRateProviderOptions>? configure = null,
Action<HttpStandardResilienceOptions>? configureResilience = null) =>
builder.AddWebRateProvider<AcmeRateProvider, AcmeRateProviderOptions>(
"Acme.Rates", // the named HttpClient
configuration, // optional; binds sectionName when supplied
sectionName,
"Acme exchange-rate options are invalid.", // the ValidateOnStart message
configure, // applied after binding
configureResilience,
static (client, options, loggerFactory, timeProvider) =>
new AcmeRateProvider(client, options, loggerFactory?.CreateLogger<AcmeRateProvider>(), timeProvider));
There are two overloads, and both take the client name, an optional configuration, the
section name, the validation message, the configure and configureResilience callbacks,
and the provider factory. The short overload above serves an options type derived from
WebRateProviderOptions, reading its validation, user agent, and timeout itself; the full
overload adds explicit validateOptions, getUserAgent, and getHttpTimeout selectors for
an options type that does not derive from it.
Consumers do not usually reference this package directly - they add a concrete provider
package (which brings this one transitively) and call its Add… method.
Part of the Bodu utility library.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Bodu.Core (>= 1.3.0)
- Bodu.Financial.DependencyInjection (>= 1.3.0)
- Bodu.Financial.ExchangeRates (>= 1.3.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Http.Resilience (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.12)
-
net8.0
- Bodu.Core (>= 1.3.0)
- Bodu.Financial.DependencyInjection (>= 1.3.0)
- Bodu.Financial.ExchangeRates (>= 1.3.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Http.Resilience (>= 8.10.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Bodu.Financial.ExchangeRates.DependencyInjection:
| Package | Downloads |
|---|---|
|
Bodu.Financial.ExchangeRates.Rba
Reserve Bank of Australia (RBA) historical exchange-rate provider for Bodu.Financial. Downloads and parses the RBA's published daily .xls files and serves them as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API and in-memory plus on-disk caching. Includes the dependency-injection registration extensions (AddRbaExchangeRates) that register the provider as a singleton backed by a configured HttpClient and bind RbaRateProviderOptions through Microsoft.Extensions.Options. |
|
|
Bodu.Financial.ExchangeRates.Fixer
Fixer (fixer.io) exchange-rate provider for Bodu.Financial. Fetches and parses the Fixer time-series and historical JSON endpoints and serves the results as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API over currency pairs. Includes the dependency-injection registration extensions (AddFixerExchangeRates) for IServiceCollection and IFinancialServiceBuilder. |
|
|
Bodu.Financial.ExchangeRates.Ecb
European Central Bank (ECB) euro foreign-exchange reference-rate provider for Bodu.Financial. Downloads and parses the ECB's published eurofxref XML feeds and serves them as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API and in-memory plus on-disk caching. Includes the dependency-injection registration extensions (AddEcbExchangeRates) for Microsoft.Extensions.DependencyInjection, with options binding and a resilient named HttpClient. |
|
|
Bodu.Financial.ExchangeRates.Fred
FRED (Federal Reserve Bank of St. Louis) exchange-rate provider for Bodu.Financial. Maps each currency pair to a FRED foreign-exchange series, fetches and parses the series observations JSON endpoint, and serves the results as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API over currency pairs. Includes the dependency-injection registration extensions (AddFredExchangeRates) for IServiceCollection and IFinancialServiceBuilder. |
|
|
Bodu.Financial.ExchangeRates.Boe
Bank of England (BoE) daily spot exchange-rate provider for Bodu.Financial. Queries the BoE's Interactive Statistical Database (IADB) CSV endpoint and serves the results as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API and in-memory plus on-disk caching. Includes dependency-injection extensions that register the provider on a configured, resilient HttpClient and bind its options. |
GitHub repositories
This package is not used by any popular GitHub repositories.