Table of Contents

CachedRate Struct

Definition

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

Represents one cached exchange-rate observation: a dated rate together with the UTC instant it was cached, which drives expiry, and the optional UTC instant the upstream data backing it was originally fetched.

public readonly struct CachedRate : IEquatable<CachedRate>
Implements
Inherited Members
Extension Methods

Constructors

CachedRate(DateOnly, decimal, DateTimeOffset, DateTimeOffset?)

Represents one cached exchange-rate observation: a dated rate together with the UTC instant it was cached, which drives expiry, and the optional UTC instant the upstream data backing it was originally fetched.

public CachedRate(DateOnly Date, decimal Rate, DateTimeOffset CachedAtUtc, DateTimeOffset? ObservedAtUtc = null)

Parameters

Date DateOnly

The observation date of the rate.

Rate decimal

The observed rate for Date.

CachedAtUtc DateTimeOffset

The UTC instant at which the rate was written to the cache.

ObservedAtUtc DateTimeOffset?

The UTC instant the upstream data backing this rate was originally fetched, distinct from CachedAtUtc the cache-write instant; null when the source did not supply it.

Properties

CachedAtUtc

The UTC instant at which the rate was written to the cache.

public DateTimeOffset CachedAtUtc { get; init; }

Property Value

DateTimeOffset

Date

The observation date of the rate.

public DateOnly Date { get; init; }

Property Value

DateOnly

ObservedAtUtc

The UTC instant the upstream data backing this rate was originally fetched, distinct from CachedAtUtc the cache-write instant; null when the source did not supply it.

public DateTimeOffset? ObservedAtUtc { get; init; }

Property Value

DateTimeOffset?

Rate

The observed rate for Date.

public decimal Rate { get; init; }

Property Value

decimal

Methods

Deconstruct(out DateOnly, out decimal, out DateTimeOffset, out DateTimeOffset?)

public void Deconstruct(out DateOnly Date, out decimal Rate, out DateTimeOffset CachedAtUtc, out DateTimeOffset? ObservedAtUtc)

Parameters

Date DateOnly
Rate decimal
CachedAtUtc DateTimeOffset
ObservedAtUtc DateTimeOffset?

Equals(CachedRate)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CachedRate other)

Parameters

other CachedRate

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

IsFresh(DateTimeOffset, TimeSpan)

Reports whether the cached rate is still fresh at asOf under the supplied caching duration.

public bool IsFresh(DateTimeOffset asOf, TimeSpan duration)

Parameters

asOf DateTimeOffset

The instant against which freshness is evaluated.

duration TimeSpan

The duration a cached rate remains fresh after it was cached.

Returns

bool

true when asOf is within duration of CachedAtUtc; otherwise false.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(CachedRate, CachedRate)

public static bool operator ==(CachedRate left, CachedRate right)

Parameters

left CachedRate
right CachedRate

Returns

bool

operator !=(CachedRate, CachedRate)

public static bool operator !=(CachedRate left, CachedRate right)

Parameters

left CachedRate
right CachedRate

Returns

bool

Applies to

ProductVersions
.NET8, 10