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
DateDateOnlyThe observation date of the rate.
RatedecimalThe observed rate for
Date.CachedAtUtcDateTimeOffsetThe UTC instant at which the rate was written to the cache.
ObservedAtUtcDateTimeOffset?The UTC instant the upstream data backing this rate was originally fetched, distinct from
CachedAtUtcthe 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
Date
The observation date of the rate.
public DateOnly Date { get; init; }
Property Value
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
Rate
The observed rate for Date.
public decimal Rate { get; init; }
Property Value
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
DateDateOnlyRatedecimalCachedAtUtcDateTimeOffsetObservedAtUtcDateTimeOffset?
Equals(CachedRate)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(CachedRate other)
Parameters
otherCachedRateAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
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
asOfDateTimeOffsetThe instant against which freshness is evaluated.
durationTimeSpanThe duration a cached rate remains fresh after it was cached.
Returns
- bool
true when
asOfis withindurationof 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
leftCachedRaterightCachedRate
Returns
operator !=(CachedRate, CachedRate)
public static bool operator !=(CachedRate left, CachedRate right)
Parameters
leftCachedRaterightCachedRate
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |