INotableDateCollisionResolver Interface
Definition
- Namespace
- Bodu.Globalization.Calendar.RangeResolution
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
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
dateDateOnlyThe emitted date the occurrences share.
collidingIReadOnlyList<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
| Product | Versions |
|---|---|
| .NET | 8, 10 |