DateRangeCoverage Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates
- Assembly
- Bodu.Financial.dll
- Package
- Bodu.Financial 1.0.0
- Source
- DateRangeCoverage.cs
Tracks the set of DateOnly ranges that have actually been observed, as a sorted list of disjoint inclusive intervals that merge on insertion but never bridge a gap.
public sealed class DateRangeCoverage
- Inheritance
-
DateRangeCoverage
- Inherited Members
- Extension Methods
Remarks
The type answers one question precisely: has every day in a requested window already been seen? Unlike a single
(min, max) envelope, it preserves interior gaps, so a window that straddles an unobserved stretch is
correctly reported as not covered. Two intervals are merged only when they overlap or touch - the later interval
begins on or before the day after the earlier one ends - so a genuine gap of one or more days keeps them separate.
Instances are not thread-safe; callers that mutate a shared instance must synchronize access themselves.
Constructors
DateRangeCoverage()
public DateRangeCoverage()
Properties
Intervals
Gets the recorded intervals in ascending order.
public IReadOnlyList<(DateOnly Start, DateOnly End)> Intervals { get; }
Property Value
- IReadOnlyList<(DateOnly Start, DateOnly End)>
The disjoint inclusive intervals that make up the coverage, ordered by start date.
IsEmpty
Gets a value indicating whether no range has been recorded.
public bool IsEmpty { get; }
Property Value
Methods
Add(DateOnly, DateOnly)
Records the inclusive range start..end as observed, merging it with any
overlapping or adjacent intervals already present.
public void Add(DateOnly start, DateOnly end)
Parameters
startDateOnlyThe inclusive first date of the observed range.
endDateOnlyThe inclusive last date of the observed range.
Exceptions
- ArgumentOutOfRangeException
Thrown when
startis later thanend.
Contains(DateOnly)
Reports whether the supplied date has been recorded.
public bool Contains(DateOnly date)
Parameters
dateDateOnlyThe date to test.
Returns
Contains(DateOnly, DateOnly)
Reports whether every day in the inclusive range start..end has been
recorded.
public bool Contains(DateOnly start, DateOnly end)
Parameters
startDateOnlyThe inclusive first date of the window to test.
endDateOnlyThe inclusive last date of the window to test.
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown when
startis later thanend.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |