ResolutionPolicy Class
Definition
- Namespace
- Bodu.Globalization.Calendar.RangeResolution
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.3.0
- Source
- ResolutionPolicy.cs
Captures the resource-level policies that govern duplicate declarations, same-day and span collisions, priority direction, category precedence, range inclusion, and the working week.
public sealed class ResolutionPolicy
- Inheritance
-
ResolutionPolicy
- Inherited Members
- Extension Methods
Remarks
The defaults mirror the recommended policy in the schema strategy: duplicates are an error, collisions keep all occurrences, higher priority wins, and the observed (emitted) occurrence controls range inclusion.
The loader applies DuplicatePolicy to the loaded document's own declarations. The service applies SameDayCollisionPolicy, then SpanCollisionPolicy, and decides inclusion in a window with ObservedDateRangePolicy.
// The policy is authored on the document; the builder route sets each knob fluently
// (the XML form is the <ResolutionPolicy> element):
NotableDateResource resource = NotableDateDocumentBuilder.Create("demo")
.WithResolutionPolicy(p => p
.WithDuplicatePolicy(DuplicatePolicy.KeepFirst)
.WithSameDayCollisionPolicy(CollisionPolicy.HighestPriorityOnly)
.WithCategoryPrecedence(NotableDateCategory.PublicHoliday, NotableDateCategory.Observance))
.AddNotableDate("new-year", "New Year's Day", NotableDateCategory.PublicHoliday, c => c
.AddRule("default", r => r.Fixed(1, 1)))
.Build();
Constructors
ResolutionPolicy(DuplicatePolicy, CollisionPolicy, CollisionPolicy, PriorityDirection, ObservedDateRangePolicy, DayOfWeekSet?, IReadOnlyList<NotableDateCategory>?)
Initializes a new instance of the ResolutionPolicy class.
public ResolutionPolicy(DuplicatePolicy duplicatePolicy = DuplicatePolicy.Error, CollisionPolicy sameDayCollisionPolicy = CollisionPolicy.KeepAll, CollisionPolicy spanCollisionPolicy = CollisionPolicy.KeepAll, PriorityDirection priorityDirection = PriorityDirection.HigherWins, ObservedDateRangePolicy observedDateRangePolicy = ObservedDateRangePolicy.ObservedOccurrenceControlsInclusion, DayOfWeekSet? workingWeek = null, IReadOnlyList<NotableDateCategory>? categoryPrecedence = null)
Parameters
duplicatePolicyDuplicatePolicyThe policy for two concepts, or two rules of one concept, that the document declares with one identifier.
sameDayCollisionPolicyCollisionPolicyThe policy applied when distinct notable dates resolve to the same emitted date.
spanCollisionPolicyCollisionPolicyThe policy applied, after same-day settlement, to occurrences connected through overlapping spans.
priorityDirectionPriorityDirectionThe direction in which numeric priority is interpreted.
observedDateRangePolicyObservedDateRangePolicyThe span of an occurrence that controls range-query inclusion.
workingWeekDayOfWeekSet?The working week that defines which weekdays are working days, or null for the default Monday-to-Friday working week (a Saturday and Sunday weekend).
categoryPrecedenceIReadOnlyList<NotableDateCategory>The category precedence, highest-winning first, applied by CategoryPriority, or null for the built-in precedence. A partial list is completed with the remaining categories in built-in order so every ranked category retains a position.
Properties
CategoryPrecedence
Gets the category precedence applied by CategoryPriority, highest-winning first.
public IReadOnlyList<NotableDateCategory> CategoryPrecedence { get; }
Property Value
- IReadOnlyList<NotableDateCategory>
The effective category precedence; every ranked category appears exactly once, with any categories an authored list omits appended in built-in order.
Default
Gets a ResolutionPolicy populated with the recommended default values.
public static ResolutionPolicy Default { get; }
Property Value
- ResolutionPolicy
A shared default policy instance.
DuplicatePolicy
Gets the policy the loader applies to two concepts, or two rules of one concept, that the document declares with one identifier.
public DuplicatePolicy DuplicatePolicy { get; }
Property Value
- DuplicatePolicy
The configured DuplicatePolicy.
Remarks
The loader applies it when the document is loaded, to that document's own declarations; a loaded resource holds no duplicate the policy settles. See DuplicatePolicy.
ObservedDateRangePolicy
Gets the span of an occurrence, emitted, actual, or either, that decides whether a range query includes it.
public ObservedDateRangePolicy ObservedDateRangePolicy { get; }
Property Value
- ObservedDateRangePolicy
The configured ObservedDateRangePolicy.
Remarks
PriorityDirection
Gets the direction in which numeric priority is interpreted.
public PriorityDirection PriorityDirection { get; }
Property Value
- PriorityDirection
The configured PriorityDirection.
SameDayCollisionPolicy
Gets the policy applied when distinct notable dates resolve to the same day.
public CollisionPolicy SameDayCollisionPolicy { get; }
Property Value
- CollisionPolicy
The configured same-day CollisionPolicy.
Remarks
The policy settles each emitted date over every occurrence emitted on it, independent of the queried range, so a multi-day occurrence that loses on its emitted date is absent from every range its span reaches into.
SpanCollisionPolicy
Gets the policy applied, after same-day settlement, to distinct notable dates whose emitted spans overlap.
public CollisionPolicy SpanCollisionPolicy { get; }
Property Value
- CollisionPolicy
The configured span CollisionPolicy.
Remarks
The policy settles every chain of occurrences connected through overlapping emitted spans that holds a multi-day occurrence, as one group ranked as a same-day group is; a chain is the whole connected run, not each overlapping pair. Occurrences that overlap only by sharing their emitted date, none of them multi-day, are left to SameDayCollisionPolicy.
A chain is settled whole, whatever window is queried: while a chain that reaches the window may continue into a civil year the query has not gathered, the query gathers one more year on that side, up to ten civil years beyond its one-year margin. A chain that never ends is settled over what was gathered at that limit.
WorkingWeek
Gets the working week that defines which weekdays are working days, and therefore which are weekend (non-working) days for weekend-sensitive triggers and working-day searches.
public DayOfWeekSet WorkingWeek { get; }
Property Value
- DayOfWeekSet
The configured working-week pattern; MondayToFriday when the resource leaves it unspecified.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |