CommonNotableDateResources Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
Provides the shared, reusable notable-date resources bundled with the library - the civil, Christian, and other thematic catalogues that define common observances (New Year's Day, Easter, Christmas, and the like) once for territory packs to import rather than redefine.
public static class CommonNotableDateResources
- Inheritance
-
CommonNotableDateResources
- Inherited Members
Remarks
A territory resource imports a common catalogue by name through an Import directive, then cherry-picks the
concepts it observes and supplies its own territory and adjustment overrides. The Resolver delegate
is the bridge: pass it to
Load(Stream, Func<string, string?>, ILogger?)
so those imports resolve against the embedded catalogues.
Resource names are the bare catalogue identifiers (for example global-core or christian-western),
matching the file names without their extension. Lookups are case-insensitive and the resolved content is cached.
// Load a territory document whose imports reference the shared catalogues, resolving those
// imports against the bundled common resources.
NotableDateResource resource = NotableDateResourceLoader.Load(
documentXml,
CommonNotableDateResources.Resolver);
NotableDateService service = new(resource);
// Resolve a single catalogue's raw XML directly when needed.
string? christianWestern = CommonNotableDateResources.Resolve("christian-western");
Properties
Resolver
Gets a resolver delegate that maps a common-catalogue name to its embedded XML content, suitable for passing to the import-aware NotableDateResourceLoader overloads.
public static Func<string, string?> Resolver { get; }
Property Value
Methods
GetResourceName(CommonNotableDateCatalog)
Gets the bare resource name (for example christian-western) for a strongly-typed catalogue, suitable for
an Import directive or a direct Resolve(string) call.
public static string GetResourceName(CommonNotableDateCatalog catalog)
Parameters
catalogCommonNotableDateCatalogThe catalogue whose resource name to return.
Returns
- string
The bare, kebab-case resource name that identifies the catalogue.
Exceptions
- ArgumentOutOfRangeException
catalogis not a defined CommonNotableDateCatalog value.
Load(CommonNotableDateCatalog)
Loads and validates a bundled catalogue into a NotableDateResource by its strongly-typed name, resolving any nested imports against the other bundled catalogues.
public static NotableDateResource Load(CommonNotableDateCatalog catalog)
Parameters
catalogCommonNotableDateCatalogThe catalogue to load.
Returns
- NotableDateResource
The materialized NotableDateResource for the requested catalogue.
Remarks
This is the direct path from a strongly-typed name to a usable resource - for example
CommonNotableDateResources.Load(CommonNotableDateCatalog.GlobalAll) materializes the entire bundled
global-all catalogue ready to hand to a NotableDateService.
The materialized resource is cached per catalogue: a NotableDateResource is immutable, so repeated loads of the same catalogue return the same instance and the parse-and-validate cost is paid once per process rather than once per call.
Exceptions
- ArgumentOutOfRangeException
catalogis not a defined CommonNotableDateCatalog value.- InvalidOperationException
The catalogue's content is not bundled with this assembly.
Resolve(CommonNotableDateCatalog)
Resolves a bundled catalogue to its embedded XML content by its strongly-typed name.
public static string? Resolve(CommonNotableDateCatalog catalog)
Parameters
catalogCommonNotableDateCatalogThe catalogue to resolve.
Returns
Exceptions
- ArgumentOutOfRangeException
catalogis not a defined CommonNotableDateCatalog value.
Resolve(string)
Resolves a common-catalogue name to its embedded XML content.
public static string? Resolve(string resourceName)
Parameters
resourceNamestringThe catalogue name, without extension (for example
christian-western).
Returns
Exceptions
- ArgumentNullException
resourceNameis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |