Table of Contents

CommonNotableDateResources Class

Definition

Namespace
Bodu.Globalization.Calendar
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.3.0
Source
CommonNotableDateResources.cs

Provides the shared, reusable notable-date resources bundled with the library - the civil, Christian, and other thematic catalogs 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 catalog 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 catalogs.

Resource names are the bare catalog 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-catalog name to its embedded XML content, suitable for passing to the import-aware NotableDateResourceLoader overloads.

public static Func<string, string?> Resolver { get; }

Property Value

Func<string, string>

A resolver over the embedded common catalogs that returns null for unknown names.

Methods

GetResourceName(CommonNotableDateCatalog)

Gets the bare resource name (for example christian-western) for a strongly-typed catalog, suitable for an Import directive or a direct Resolve(string) call.

public static string GetResourceName(CommonNotableDateCatalog catalog)

Parameters

catalog CommonNotableDateCatalog

The catalog whose resource name to return.

Returns

string

The bare, kebab-case resource name that identifies the catalog.

Exceptions

ArgumentOutOfRangeException

catalog is not a defined CommonNotableDateCatalog value.

Load(CommonNotableDateCatalog)

Loads and validates a bundled catalog into a NotableDateResource by its strongly-typed name, resolving any nested imports against the other bundled catalogs.

public static NotableDateResource Load(CommonNotableDateCatalog catalog)

Parameters

catalog CommonNotableDateCatalog

The catalog to load.

Returns

NotableDateResource

The materialized NotableDateResource for the requested catalog.

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 catalog ready to hand to a NotableDateService.

The materialized resource is cached per catalog: a NotableDateResource is immutable, so repeated loads of the same catalog return the same instance and the parse-and-validate cost is paid once per process rather than once per call.

Exceptions

ArgumentOutOfRangeException

catalog is not a defined CommonNotableDateCatalog value.

InvalidOperationException

The catalog's content is not bundled with this assembly.

Resolve(CommonNotableDateCatalog)

Resolves a bundled catalog to its embedded XML content by its strongly-typed name.

public static string? Resolve(CommonNotableDateCatalog catalog)

Parameters

catalog CommonNotableDateCatalog

The catalog to resolve.

Returns

string

The catalog XML, or null when the catalog is not bundled with this assembly.

Exceptions

ArgumentOutOfRangeException

catalog is not a defined CommonNotableDateCatalog value.

Resolve(string)

Resolves a common-catalog name to its embedded XML content.

public static string? Resolve(string resourceName)

Parameters

resourceName string

The catalog name, without extension (for example christian-western).

Returns

string

The catalog XML, or null when no catalog of that name is bundled.

Exceptions

ArgumentNullException

resourceName is null.

Applies to

ProductVersions
.NET8, 10