Table of Contents

INotableDateCollisionResolver Interface

Definition

Namespace
Bodu.Globalization.Calendar.RangeResolution
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.0.1
Source
INotableDateCollisionResolver.cs

Resolves a set of notable-date occurrences that share the same emitted date, used when the resource's same-day collision policy is Custom.

public interface INotableDateCollisionResolver
Extension Methods

Examples

// Keep only the highest-priority occurrence on a contested day, breaking ties by name.
public sealed class HighestPriorityResolver : INotableDateCollisionResolver
{
    public IReadOnlyList<NotableDate> Resolve(DateOnly date, IReadOnlyList<NotableDate> colliding)
    {
        int best = colliding.Max(n => n.Priority);
        return colliding
            .Where(n => n.Priority == best)
            .OrderBy(n => n.DisplayName, StringComparer.Ordinal)
            .ToList();
    }
}

Remarks

The resolver is consulted once per group of two or more occurrences that land on the same emitted date. It returns the subset to keep, in the order they should appear; returning an empty list suppresses the date entirely. Pass an implementation to the collaborator-aware NotableDateService constructor, and set the resource's same-day collision policy to Custom so the resolver is invoked.

Methods

Resolve(DateOnly, IReadOnlyList<NotableDate>)

Selects which of the colliding occurrences to keep.

IReadOnlyList<NotableDate> Resolve(DateOnly date, IReadOnlyList<NotableDate> colliding)

Parameters

date DateOnly

The emitted date the occurrences share.

colliding IReadOnlyList<NotableDate>

The two or more occurrences emitted on the date, in resolution order.

Returns

IReadOnlyList<NotableDate>

The occurrences to keep; an empty result suppresses the date entirely.

Applies to

ProductVersions
.NET8, 10

See Also