Table of Contents

INotableDateProvider Interface

Definition

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

Contributes fully-formed notable-date occurrences to a NotableDateService in code, for sources that cannot be expressed as authored resource rules.

public interface INotableDateProvider
Extension Methods

Examples

// Contribute a company founding anniversary that is not expressible as an authored rule.
public sealed class FoundingDayProvider : INotableDateProvider
{
    public IEnumerable<NotableDate> GetNotableDates(DateRange range, string territory)
    {
        for (int year = range.StartDate.Year; year <= range.EndDate.Year; year++)
        {
            DateOnly date = new(year, 6, 15);
            yield return new NotableDate(
                Date: date,
                ActualDate: date,
                IsObserved: false,
                Identity: new NotableDateRuleIdentity("company", "company-founding", "fixed"),
                DisplayName: "Company Founding Day",
                TerritoryCode: territory,
                Category: NotableDateCategory.Observance,
                Priority: 0,
                DurationDays: 1,
                IsNonWorkingDay: false,
                Tags: Array.Empty<string>(),
                AdjustmentPolicyId: null,
                AdjustmentReason: null);
        }
    }
}

// Register the provider through the collaborator-aware constructor.
NotableDateService service = new(
    resource, algorithms: null, collisionResolver: null, handlers: null,
    triggerHandlers: null, providers: new[] { new FoundingDayProvider() });

Remarks

A provider returns finished NotableDate occurrences - date and all metadata - for a requested window and territory, complementing the resource-authored rules. It is the code-first counterpart to authoring a rule, and is registered with the service through the provider-aware constructor.

Provider occurrences are terminal: the service emits them as supplied (after intersecting them with the requested range and applying any query filter), so they do not pass through adjustment policies, declarative overrides, territory specificity, or the occupied-day interaction that resource rules participate in. They do take part in the final date ordering and the resource's same-day collision policy alongside resource occurrences. A provider that needs observed-date shifting must compute it itself.

Methods

GetNotableDates(DateRange, string)

Produces the notable-date occurrences that fall within the requested range for the territory.

IEnumerable<NotableDate> GetNotableDates(DateRange range, string territory)

Parameters

range DateRange

The inclusive range being resolved.

territory string

The requested territory code.

Returns

IEnumerable<NotableDate>

The occurrences the provider contributes; an empty sequence when it has none. Occurrences whose span does not intersect range are ignored by the service.

Applies to

ProductVersions
.NET8, 10

See Also