Table of Contents

EcbEndpointOptions Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.Ecb.dll
Package
Bodu.Financial.ExchangeRates.Ecb 0.7.1
Source
EcbEndpointOptions.cs

Configures the provider's connection to the European Central Bank's eurofxref endpoints: where the feed files are published and how the HTTP requests that fetch them are shaped.

public sealed class EcbEndpointOptions
Inheritance
EcbEndpointOptions
Inherited Members
Extension Methods

Remarks

This object isolates the network-facing settings from the behavioural options on EcbRateProviderOptions, so the host, transport timeout, and request identity can be pointed at a mirror or proxy of the ECB feeds - or simply tuned - without touching caching, feed-selection, or alias configuration. The absolute URL of a feed is composed from BaseUrl and the feed's relative FileName through ResolveFeedUrl(EcbRateFeed).

Every member carries a working default, so the object binds cleanly through Microsoft.Extensions.Options and requires no configuration for the common case.

Constructors

EcbEndpointOptions()

public EcbEndpointOptions()

Properties

BaseUrl

Gets or sets the base URL under which the ECB publishes its eurofxref reference-rate files. Should end with a trailing slash so feed file names resolve as relative paths.

public Uri BaseUrl { get; set; }

Property Value

Uri

The base URL; defaults to the ECB eurofxref statistics path.

HttpTimeout

Gets or sets the HTTP request timeout applied to feed downloads by the dependency-injection registration.

public TimeSpan HttpTimeout { get; set; }

Property Value

TimeSpan

The HTTP timeout; defaults to 30 seconds.

UserAgent

Gets or sets the User-Agent header applied to feed downloads by the dependency-injection registration.

public string UserAgent { get; set; }

Property Value

string

The user-agent string; defaults to a Bodu identifier.

Methods

ResolveFeedUrl(EcbRateFeed)

Resolves the absolute download URL for a feed by combining BaseUrl with the feed's relative file name.

public Uri ResolveFeedUrl(EcbRateFeed feed)

Parameters

feed EcbRateFeed

The feed whose URL is required.

Returns

Uri

The absolute feed URL.

Exceptions

ArgumentNullException

Thrown when feed is null.

InvalidOperationException

Thrown when BaseUrl has not been configured.

TryValidate(out string?)

Attempts to validate the endpoint options without throwing, reporting the first invariant that is violated.

public bool TryValidate(out string? error)

Parameters

error string

When this method returns false, a message describing the first violated invariant; otherwise null.

Returns

bool

true when every invariant holds; otherwise false.

Validate()

Validates the endpoint options, throwing when a required value is missing or an invariant is violated.

public void Validate()

Exceptions

ArgumentException

Thrown when BaseUrl is null, or HttpTimeout is not greater than zero.

Applies to

ProductVersions
.NET8, 10