Table of Contents

CommonNotableDateResources Class

Definition

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

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

Func<string, string>

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

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

catalog CommonNotableDateCatalog

The catalogue whose resource name to return.

Returns

string

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

Exceptions

ArgumentOutOfRangeException

catalog is 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

catalog CommonNotableDateCatalog

The 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

catalog is 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

catalog CommonNotableDateCatalog

The catalogue to resolve.

Returns

string

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

Exceptions

ArgumentOutOfRangeException

catalog is not a defined CommonNotableDateCatalog value.

Resolve(string)

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

public static string? Resolve(string resourceName)

Parameters

resourceName string

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

Returns

string

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

Exceptions

ArgumentNullException

resourceName is null.

Applies to

ProductVersions
.NET8, 10