CurrencyPairRoute Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates.Caching
- Assembly
- Bodu.Financial.ExchangeRates.Caching.dll
- Package
- Bodu.Financial.ExchangeRates.Caching 1.0.0
- Source
- CurrencyPairRoute.cs
Describes how an AggregatingRateProvider resolves a specific currency pair: the ordered child provider names to consult and, optionally, the strategy to combine them.
public sealed class CurrencyPairRoute
- Inheritance
-
CurrencyPairRoute
- Inherited Members
- Extension Methods
Remarks
A route lets a single aggregator prefer different sources for different pairs - for example AUD/USD via
[RBA, ECB] while USD/GBP prefers [ECB, RBA] - and optionally override the aggregator's default
strategy for that pair.
using Bodu.Financial.Currencies;
using Bodu.Financial.ExchangeRates;
using Bodu.Financial.ExchangeRates.Caching;
var options = new RateAggregationOptions();
// AUD/USD prefers the RBA; unrouted pairs keep the aggregator's default child order.
options.Routes[new CurrencyPair(CurrencyCode.AUD, CurrencyCode.USD)] =
new CurrencyPairRoute(new[] { "RBA", "ECB" });
// EUR/USD is averaged across both sources - a per-pair strategy override.
options.Routes[new CurrencyPair(CurrencyCode.EUR, CurrencyCode.USD)] =
new CurrencyPairRoute(new[] { "ECB", "RBA" }, new AverageStrategy());
Constructors
CurrencyPairRoute(IEnumerable<string>, IRateAggregationStrategy?)
Initializes a new instance of the CurrencyPairRoute class.
public CurrencyPairRoute(IEnumerable<string> providerOrder, IRateAggregationStrategy? strategy = null)
Parameters
providerOrderIEnumerable<string>The ordered child provider names to consult for the routed pair.
strategyIRateAggregationStrategyThe strategy used to combine the routed providers, or null to use the aggregator's default strategy.
Exceptions
- ArgumentNullException
Thrown when
providerOrderis null.- ArgumentException
Thrown when
providerOrderis empty or contains a blank name.
Properties
ProviderOrder
Gets the ordered child provider names consulted for the routed pair.
public IReadOnlyList<string> ProviderOrder { get; }
Property Value
- IReadOnlyList<string>
The ordered provider names.
Strategy
Gets the strategy used to combine the routed providers, if overridden.
public IRateAggregationStrategy? Strategy { get; }
Property Value
- IRateAggregationStrategy
The route-specific strategy, or null to use the aggregator's default strategy.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |