NotableDateCacheWarmupOptions Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Caching
- Assembly
- Bodu.Globalization.Calendar.Caching.dll
- Package
- Bodu.Globalization.Calendar.Caching 1.0.0
Configures the startup cache warm-up registered through AddNotableDateCacheWarmup: the territories to warm
and the span of civil years they are warmed over.
public sealed class NotableDateCacheWarmupOptions
- Inheritance
-
NotableDateCacheWarmupOptions
- Inherited Members
- Extension Methods
Remarks
The warmed span defaults to a rolling window around the current UTC civil year - [year −
YearsBehind, year + YearsAhead], evaluated when the warm-up runs - so a long-lived
deployment always warms the years users actually query. Either bound can be pinned with FirstYear or
LastYear; a pinned bound replaces its rolling default independently of the other.
Constructors
NotableDateCacheWarmupOptions()
public NotableDateCacheWarmupOptions()
Properties
FirstYear
Gets or sets the fixed inclusive first civil year of the warmed span, replacing the rolling YearsBehind start.
public int? FirstYear { get; set; }
Property Value
- int?
The fixed first year, or null to derive it from YearsBehind.
LastYear
Gets or sets the fixed inclusive last civil year of the warmed span, replacing the rolling YearsAhead end.
public int? LastYear { get; set; }
Property Value
- int?
The fixed last year, or null to derive it from YearsAhead.
Territories
Gets the territory codes to warm.
public IList<string> Territories { get; }
Property Value
YearsAhead
Gets or sets the number of civil years after the current UTC year the warmed span reaches forward, used when LastYear is not set.
public int YearsAhead { get; set; }
Property Value
- int
The rolling years ahead; defaults to 1. Must not be negative.
YearsBehind
Gets or sets the number of civil years before the current UTC year the warmed span reaches back, used when FirstYear is not set.
public int YearsBehind { get; set; }
Property Value
- int
The rolling years behind; defaults to 0. Must not be negative.
Methods
TryValidate(out string?)
Attempts to validate the options without throwing, reporting the first invariant that is violated.
public bool TryValidate(out string? error)
Parameters
errorstringWhen this method returns false, a message describing the first violated invariant; otherwise null.
Returns
Validate()
Validates the option values, throwing when a rule is violated.
public void Validate()
Remarks
This throwing form preserves the ParamName of the offending option. The dependency-injection registration
instead wires TryValidate(out string?) into ValidateOnStart.
Exceptions
- ArgumentException
Thrown when Territories is empty or contains a blank code, when YearsBehind or YearsAhead is negative, when a fixed year is outside the representable calendar range, or when FirstYear and LastYear are both set and inverted.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |