NotableDateResource Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
- Source
- NotableDateResource.cs
Represents a fully loaded and validated notable-date document resource: its resolution policy, reusable adjustment policies, and notable-date concepts.
public sealed class NotableDateResource
- Inheritance
-
NotableDateResource
- Inherited Members
- Extension Methods
Remarks
A resource is immutable once loaded. Imports and override operations are applied during loading, so the concepts and rules exposed here are the effective set used by the resolver.
How obtained. A resource is normally produced by NotableDateResourceLoader, a data
pack factory, or NotableDateDocumentBuilder.Build, then handed to a NotableDateService. The
public constructor exists for advanced code-first assembly; most consumers never call it directly.
// Load a resource, then inspect its contents before building a service over it.
NotableDateResource resource = NotableDateResourceLoader.Load(documentXml);
Console.WriteLine($"Resource {resource.ResourceId} (schema {resource.SchemaVersion})");
Console.WriteLine($"Concepts: {resource.NotableDates.Count}, rules: {resource.RuleCount}");
// Look up a single concept by its identifier.
NotableDateDefinition? christmas = resource.FindDefinition("christmas-day");
NotableDateService service = new(resource);
Constructors
NotableDateResource(string, string, ResolutionPolicy, IEnumerable<AdjustmentPolicy>, IEnumerable<NotableDateDefinition>)
Initializes a new instance of the NotableDateResource class.
public NotableDateResource(string resourceId, string schemaVersion, ResolutionPolicy resolutionPolicy, IEnumerable<AdjustmentPolicy> adjustmentPolicies, IEnumerable<NotableDateDefinition> notableDates)
Parameters
resourceIdstringThe stable identifier of the resource.
schemaVersionstringThe schema version declared by the resource.
resolutionPolicyResolutionPolicyThe resource-level resolution policy.
adjustmentPoliciesIEnumerable<AdjustmentPolicy>The reusable adjustment policies declared by the resource.
notableDatesIEnumerable<NotableDateDefinition>The notable-date concepts declared by the resource.
Exceptions
- ArgumentNullException
Any argument is null.
Properties
AdjustmentPolicies
Gets the reusable adjustment policies declared by the resource.
public IReadOnlyList<AdjustmentPolicy> AdjustmentPolicies { get; }
Property Value
- IReadOnlyList<AdjustmentPolicy>
The adjustment policies; empty when none are declared.
NotableDates
Gets the notable-date concepts declared by the resource.
public IReadOnlyList<NotableDateDefinition> NotableDates { get; }
Property Value
- IReadOnlyList<NotableDateDefinition>
The notable-date concepts.
ResolutionPolicy
Gets the resource-level resolution policy.
public ResolutionPolicy ResolutionPolicy { get; }
Property Value
ResourceId
Gets the stable identifier of the resource.
public string ResourceId { get; }
Property Value
- string
The resource id.
RuleCount
Gets the total number of rules across every notable-date concept in the resource.
public int RuleCount { get; }
Property Value
- int
The aggregate rule count.
SchemaVersion
Gets the schema version declared by the resource.
public string SchemaVersion { get; }
Property Value
- string
The schema version string.
Methods
FindAdjustmentPolicy(string)
Finds the reusable adjustment policy with the supplied identifier.
public AdjustmentPolicy? FindAdjustmentPolicy(string id)
Parameters
idstringThe policy identifier to locate.
Returns
- AdjustmentPolicy
The matching AdjustmentPolicy, or null when none exists.
Exceptions
- ArgumentNullException
idis null.
FindDefinition(string)
Finds the notable-date concept with the supplied identifier.
public NotableDateDefinition? FindDefinition(string id)
Parameters
idstringThe concept identifier to locate.
Returns
- NotableDateDefinition
The matching NotableDateDefinition, or null when none exists.
Exceptions
- ArgumentNullException
idis null.
GetIdentity(NotableDateDefinition, NotableDateRule)
Builds the full identity of a rule belonging to this resource.
public NotableDateRuleIdentity GetIdentity(NotableDateDefinition definition, NotableDateRule rule)
Parameters
definitionNotableDateDefinitionThe notable-date concept that owns the rule.
ruleNotableDateRuleThe rule whose identity is required.
Returns
- NotableDateRuleIdentity
The composite NotableDateRuleIdentity.
Exceptions
- ArgumentNullException
definitionorruleis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |