ReloadableNotableDateService Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
An INotableDateService that resolves against the resource currently supplied by an INotableDateResourceProvider, rebuilding its resolution state whenever that resource is reloaded.
public sealed class ReloadableNotableDateService : INotableDateService
- Inheritance
-
ReloadableNotableDateService
- Implements
- Inherited Members
- Extension Methods
Examples
MutableNotableDateResourceProvider provider = new(NotableDateResourceLoader.Load(initialXml));
INotableDateService service = new ReloadableNotableDateService(provider);
IReadOnlyList<NotableDate> before = service.Resolve(2026, "US");
provider.Reload(NotableDateResourceLoader.Load(updatedXml));
IReadOnlyList<NotableDate> after = service.Resolve(2026, "US"); // reflects the reloaded data
Remarks
This service is a drop-in replacement for NotableDateService in scenarios where the underlying data is reloaded at runtime - for example a dependency-injection singleton whose source document changes. Each query reads the provider's current resource; when it differs from the one the inner service was built from, a fresh inner service is constructed. Construction is cheap, so reloads are inexpensive.
Logging. The constructors accept an optional ILogger (defaulting to Instance, so logging is opt-in). When supplied, the service records each rebuild of its resolution state after observing a reloaded resource at Debug. This level is fixed.
Constructors
ReloadableNotableDateService(INotableDateResourceProvider, NotableDateServiceOptions?, ILogger?)
Initializes a new instance of the ReloadableNotableDateService class with the optional collaborators propagated to each rebuilt inner service.
public ReloadableNotableDateService(INotableDateResourceProvider provider, NotableDateServiceOptions? options, ILogger? logger = null)
Parameters
providerINotableDateResourceProviderThe provider supplying the resource currently in effect.
optionsNotableDateServiceOptionsThe optional collaborators propagated to each rebuilt inner NotableDateService, or null for built-ins only.
loggerILoggerThe logger that records resolution-state rebuilds. null selects Instance.
Exceptions
- ArgumentNullException
provideris null.
ReloadableNotableDateService(INotableDateResourceProvider, ILogger?)
Initializes a new instance of the ReloadableNotableDateService class.
public ReloadableNotableDateService(INotableDateResourceProvider provider, ILogger? logger = null)
Parameters
providerINotableDateResourceProviderThe provider supplying the resource currently in effect.
loggerILoggerThe logger that records resolution-state rebuilds. null selects Instance.
Exceptions
- ArgumentNullException
provideris null.
Methods
GetSupportedCalendars()
Gets the distinct calendar systems any rule in the resource is expressed in.
public IReadOnlyList<CalendarSystem> GetSupportedCalendars()
Returns
- IReadOnlyList<CalendarSystem>
The calendar systems in use, in ascending order.
GetSupportedTerritories()
Gets the distinct territories any rule in the resource is scoped to.
public IReadOnlyList<string> GetSupportedTerritories()
Returns
- IReadOnlyList<string>
The scoped territory codes in case-insensitive ascending order; empty when every rule is global (unscoped).
Resolve(DateRange, string)
Resolves the notable-date occurrences emitted within an inclusive date range for the requested territory.
public IReadOnlyList<NotableDate> Resolve(DateRange range, string territory)
Parameters
rangeDateRangeThe inclusive range of days to resolve.
territorystringThe requested territory code.
Returns
- IReadOnlyList<NotableDate>
The occurrences whose emitted date falls within the range, ordered by date then identity.
Resolve(DateRange, string, NotableDateFilter)
Resolves the notable-date occurrences emitted within an inclusive date range for the requested territory, restricted to those matching the supplied filter.
public IReadOnlyList<NotableDate> Resolve(DateRange range, string territory, NotableDateFilter filter)
Parameters
rangeDateRangeThe inclusive range of days to resolve.
territorystringThe requested territory code.
filterNotableDateFilterThe filter that emitted occurrences must satisfy.
Returns
- IReadOnlyList<NotableDate>
The matching occurrences, ordered by date then identity.
Resolve(DateOnly, string)
Resolves the notable-date occurrences emitted on a single day for the requested territory.
public IReadOnlyList<NotableDate> Resolve(DateOnly date, string territory)
Parameters
Returns
- IReadOnlyList<NotableDate>
The occurrences whose emitted date equals
date; empty when there are none.
Resolve(DateOnly, string, NotableDateFilter)
Resolves the notable-date occurrences emitted on a single day for the requested territory, restricted to those matching the supplied filter.
public IReadOnlyList<NotableDate> Resolve(DateOnly date, string territory, NotableDateFilter filter)
Parameters
dateDateOnlyThe day to resolve.
territorystringThe requested territory code.
filterNotableDateFilterThe filter that emitted occurrences must satisfy.
Returns
- IReadOnlyList<NotableDate>
The matching occurrences; empty when there are none.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |