IAggregatedRateBuilder Interface
Definition
- Namespace
- Bodu.Financial.ExchangeRates.Caching
- Assembly
- Bodu.Financial.ExchangeRates.Caching.dll
- Package
- Bodu.Financial.ExchangeRates.Caching 1.0.0
Builds the set of named, individually cached children an AggregatingRateProvider groups, together with its default strategy and per-currency-pair routing.
public interface IAggregatedRateBuilder
- Extension Methods
Remarks
Each child is registered as a keyed IDatedRateProvider (and resolvable by name through the service catalog) wrapped in its own CachingRateProvider, so a specific source can be obtained directly while the aggregator applies the configured strategy and routing.
services.AddFinancialService()
.AddAggregatedRateProvider(agg => agg
.AddCachedChild<RbaRateProvider>("RBA")
.AddCachedChild<EcbRateProvider>("ECB")
.UseDefaultStrategy(new PriorityFallbackStrategy())
.MapPair(new CurrencyPair(CurrencyCode.AUD, CurrencyCode.USD), "RBA", "ECB")
.MapPair(new CurrencyPair(CurrencyCode.EUR, CurrencyCode.USD), new AverageStrategy(), "ECB", "RBA"));
Methods
AddCachedChild(string, Func<IServiceProvider, IDatedRateProvider>, Func<IServiceProvider, string, IRateCache>?)
Adds a cached child resolved by a factory.
IAggregatedRateBuilder AddCachedChild(string name, Func<IServiceProvider, IDatedRateProvider> factory, Func<IServiceProvider, string, IRateCache>? cacheFactory = null)
Parameters
namestringThe name the child is referenced and cached under.
factoryFunc<IServiceProvider, IDatedRateProvider>A factory that resolves the child source from the service provider.
cacheFactoryFunc<IServiceProvider, string, IRateCache>An optional factory producing the child's IRateCache from the service provider and the child name. When null, the registration's default cache is used.
Returns
- IAggregatedRateBuilder
The same builder, for chaining.
Exceptions
- ArgumentNullException
Thrown when
factoryis null.- ArgumentException
Thrown when
nameis empty or white space.
AddCachedChild<TProvider>(string, Func<IServiceProvider, string, IRateCache>?)
Adds a cached child resolved from the container by its concrete type.
IAggregatedRateBuilder AddCachedChild<TProvider>(string name, Func<IServiceProvider, string, IRateCache>? cacheFactory = null) where TProvider : class, IDatedRateProvider
Parameters
namestringThe name the child is referenced and cached under.
cacheFactoryFunc<IServiceProvider, string, IRateCache>An optional factory producing the child's IRateCache from the service provider and the child name. When null, the registration's default cache is used.
Returns
- IAggregatedRateBuilder
The same builder, for chaining.
Type Parameters
TProviderThe concrete provider type to resolve and cache.
Exceptions
- ArgumentException
Thrown when
nameis empty or white space.
MapPair(CurrencyPair, IRateAggregationStrategy, params string[])
Routes a currency pair to an ordered set of child names, combined with a pair-specific strategy.
IAggregatedRateBuilder MapPair(CurrencyPair pair, IRateAggregationStrategy strategy, params string[] providerOrder)
Parameters
pairCurrencyPairThe currency pair to route.
strategyIRateAggregationStrategyThe strategy used to combine the routed children.
providerOrderstring[]The ordered child names to consult for the pair.
Returns
- IAggregatedRateBuilder
The same builder, for chaining.
Exceptions
- ArgumentNullException
Thrown when
strategyorproviderOrderis null.
MapPair(CurrencyPair, params string[])
Routes a currency pair to an ordered set of child names, combined with the default strategy.
IAggregatedRateBuilder MapPair(CurrencyPair pair, params string[] providerOrder)
Parameters
pairCurrencyPairThe currency pair to route.
providerOrderstring[]The ordered child names to consult for the pair.
Returns
- IAggregatedRateBuilder
The same builder, for chaining.
Exceptions
- ArgumentNullException
Thrown when
providerOrderis null.
UseDefaultStrategy(IRateAggregationStrategy)
Sets the strategy applied to pairs without a route-specific strategy.
IAggregatedRateBuilder UseDefaultStrategy(IRateAggregationStrategy strategy)
Parameters
strategyIRateAggregationStrategyThe default aggregation strategy.
Returns
- IAggregatedRateBuilder
The same builder, for chaining.
Exceptions
- ArgumentNullException
Thrown when
strategyis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |