Table of Contents

IAggregatedRateBuilder Interface

Definition

Namespace
Bodu.Financial.ExchangeRates.Caching
Assembly
Bodu.Financial.ExchangeRates.Caching.dll
Package
Bodu.Financial.ExchangeRates.Caching 1.0.0
Source
IAggregatedRateBuilder.cs

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

name string

The name the child is referenced and cached under.

factory Func<IServiceProvider, IDatedRateProvider>

A factory that resolves the child source from the service provider.

cacheFactory Func<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 factory is null.

ArgumentException

Thrown when name is 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

name string

The name the child is referenced and cached under.

cacheFactory Func<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

TProvider

The concrete provider type to resolve and cache.

Exceptions

ArgumentException

Thrown when name is 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

pair CurrencyPair

The currency pair to route.

strategy IRateAggregationStrategy

The strategy used to combine the routed children.

providerOrder string[]

The ordered child names to consult for the pair.

Returns

IAggregatedRateBuilder

The same builder, for chaining.

Exceptions

ArgumentNullException

Thrown when strategy or providerOrder is 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

pair CurrencyPair

The currency pair to route.

providerOrder string[]

The ordered child names to consult for the pair.

Returns

IAggregatedRateBuilder

The same builder, for chaining.

Exceptions

ArgumentNullException

Thrown when providerOrder is null.

UseDefaultStrategy(IRateAggregationStrategy)

Sets the strategy applied to pairs without a route-specific strategy.

IAggregatedRateBuilder UseDefaultStrategy(IRateAggregationStrategy strategy)

Parameters

strategy IRateAggregationStrategy

The default aggregation strategy.

Returns

IAggregatedRateBuilder

The same builder, for chaining.

Exceptions

ArgumentNullException

Thrown when strategy is null.

Applies to

ProductVersions
.NET8, 10