IAdjustmentTriggerHandler Interface
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
Decides whether an adjustment policy whose trigger is Custom fires for a calculated occurrence, supplementing the engine's built-in triggers with caller-supplied logic.
public interface IAdjustmentTriggerHandler
- Extension Methods
Examples
// Fire only in leap years, reading a policy parameter for the toggle.
public sealed class LeapYearTriggerHandler : IAdjustmentTriggerHandler
{
public bool ShouldAdjust(AdjustmentTriggerContext context)
{
bool enabled = !context.Parameters.TryGetValue("enabled", out string? flag)
|| bool.Parse(flag);
return enabled && DateTime.IsLeapYear(context.BaseDate.Year);
}
}
Remarks
A trigger handler is bound to a policy through the policy's trigger handler key and is consulted during candidate gathering, before the observed date is computed. It receives the calculated date together with the surrounding resolution context, so it can resolve other rules for the same year when deciding whether to fire.
Methods
ShouldAdjust(AdjustmentTriggerContext)
Determines whether the policy fires for the calculated occurrence.
bool ShouldAdjust(AdjustmentTriggerContext context)
Parameters
contextAdjustmentTriggerContextThe context describing the occurrence being evaluated.
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |