StrategyResolutionContext Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Algorithms
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
Provides a strategy with access to the surrounding resource so that referential strategies (such as OffsetFromRuleStrategy) can resolve the occurrence of another rule for the same year.
public sealed class StrategyResolutionContext
- Inheritance
-
StrategyResolutionContext
- Inherited Members
- Extension Methods
Remarks
The context maintains an in-progress set keyed by rule identity so that a circular reference between offset rules resolves to null rather than recursing without end.
Constructors
StrategyResolutionContext(NotableDateResource)
Initializes a new instance of the StrategyResolutionContext class.
public StrategyResolutionContext(NotableDateResource resource)
Parameters
resourceNotableDateResourceThe resource that referential strategies resolve against.
Exceptions
- ArgumentNullException
resourceis null.
StrategyResolutionContext(NotableDateResource, INotableDateAlgorithmRegistry?, string?)
Initializes a new instance of the StrategyResolutionContext class with a custom algorithm registry.
public StrategyResolutionContext(NotableDateResource resource, INotableDateAlgorithmRegistry? algorithms, string? territory = null)
Parameters
resourceNotableDateResourceThe resource that referential strategies resolve against.
algorithmsINotableDateAlgorithmRegistryThe custom algorithm registry, or null for built-ins only.
territorystringThe territory being resolved, consulted by business-day strategies; defaults to an empty territory.
Exceptions
- ArgumentNullException
resourceis null.
Properties
Algorithms
Gets the custom algorithm registry consulted for keys the built-in catalogue does not recognize.
public INotableDateAlgorithmRegistry? Algorithms { get; }
Property Value
- INotableDateAlgorithmRegistry
The registry, or null when only built-in algorithms are available.
Territory
Gets the territory being resolved, used by business-day strategies to determine non-working days.
public string Territory { get; }
Property Value
- string
The territory code; an empty string when the context is not territory-scoped.
Methods
AddWorkingDays(DateOnly, int, string)
Moves a date by a signed number of working days for a territory, skipping non-working days.
public DateOnly? AddWorkingDays(DateOnly origin, int workingDays, string territory)
Parameters
originDateOnlyThe origin date, which is not counted as one of the offset working days.
workingDaysintThe signed number of working days to move; positive forward, negative backward.
territorystringThe territory whose non-working days apply.
Returns
IsWorkingDay(DateOnly, string)
Determines whether a date is a working day for a territory, using the resource's working-week pattern and every applicable non-working notable-date occurrence.
public bool IsWorkingDay(DateOnly date, string territory)
Parameters
Returns
Remarks
The result is deterministic and independent of resource-declaration order: a non-working day is a rest day outside the working week, or a day claimed by a non-working rule's base occurrence (and its fixed-duration span).
A business-day strategy consulted while those non-working days are being built sees rest days only, so a non-working rule that counts working days resolves against the working week alone.
ReferenceIsRecurring(string, string?)
Determines whether a rule referenced by id resolves to a recurrence source, which cannot be used as a singular reference.
public bool ReferenceIsRecurring(string notableDateRef, string? ruleRef)
Parameters
notableDateRefstringThe identifier of the referenced notable-date concept.
ruleRefstringThe identifier of the referenced rule, or null to use its sole rule.
Returns
ResolveReference(string, string?, int)
Resolves the occurrence of a referenced rule for the supplied Gregorian year.
public DateOnly? ResolveReference(string notableDateRef, string? ruleRef, int year)
Parameters
notableDateRefstringThe identifier of the referenced notable-date concept.
ruleRefstringThe identifier of the referenced rule, or null to use its sole rule.
yearintThe Gregorian year to resolve.
Returns
ResolveReferenceAll(string, string?, int)
Resolves every occurrence of a referenced rule for the supplied Gregorian year.
public IReadOnlyList<DateOnly> ResolveReferenceAll(string notableDateRef, string? ruleRef, int year)
Parameters
notableDateRefstringThe identifier of the referenced notable-date concept.
ruleRefstringThe identifier of the referenced rule, or null to use its sole rule.
yearintThe Gregorian year to resolve.
Returns
- IReadOnlyList<DateOnly>
The referenced occurrences in ascending chronological order; empty when the reference cannot be resolved (missing, ambiguous, circular, or producing no occurrence).
Remarks
A non-Gregorian anchor's short lunar month and day can recur twice in one Gregorian year, so a referential strategy that projects each anchor occurrence must resolve through this member rather than ResolveReference(string, string?, int), which yields only the year's first occurrence.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |