YahooServiceCollectionExtensions Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates
- Assembly
- Bodu.Financial.ExchangeRates.Yahoo.dll
- Package
- Bodu.Financial.ExchangeRates.Yahoo 0.7.1
Provides a one-call entry point that registers the core Bodu.Financial services together with the Yahoo Finance exchange-rate provider.
public static class YahooServiceCollectionExtensions
- Inheritance
-
YahooServiceCollectionExtensions
- Inherited Members
Methods
AddYahooExchangeRates(IServiceCollection, IConfiguration?, string, Action<YahooRateProviderOptions>?)
Registers the core Bodu.Financial services and the Yahoo Finance exchange-rate provider.
public static IFinancialServiceBuilder AddYahooExchangeRates(this IServiceCollection services, IConfiguration? configuration = null, string sectionName = "Financial:Yahoo", Action<YahooRateProviderOptions>? configure = null)
Parameters
servicesIServiceCollectionThe service collection to register into.
configurationIConfigurationAn optional configuration root. When supplied, FinancialOptions is bound from the
Financialsection and YahooRateProviderOptions fromsectionName.sectionNamestringThe Yahoo configuration section name. Defaults to
Financial:Yahoo.configureAction<YahooRateProviderOptions>An optional callback applied after Yahoo configuration binding.
Returns
- IFinancialServiceBuilder
An IFinancialServiceBuilder for further composition.
Examples
IServiceCollection services = new ServiceCollection();
services.AddYahooExchangeRates(configuration, configure: options =>
{
options.UserAgent = "my-app/1.0";
options.HttpTimeout = TimeSpan.FromSeconds(15);
});
ServiceProvider provider = services.BuildServiceProvider();
var rates = provider.GetRequiredService<IDatedRateProvider>();
Exceptions
- ArgumentNullException
Thrown when
servicesis null.- ArgumentException
Thrown when
sectionNameis empty or white space.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |