Table of Contents

IAdjustmentHandler Interface

Definition

Namespace
Bodu.Globalization.Calendar
Assembly
Bodu.Globalization.Calendar.dll
Package
Bodu.Globalization.Calendar 1.0.1
Source
IAdjustmentHandler.cs

Computes the observed date of an occurrence for an adjustment policy whose action is Custom, supplementing the engine's built-in actions with caller-supplied logic.

public interface IAdjustmentHandler
Extension Methods

Examples

// Move the occurrence to the next day that is not already claimed by another non-working date.
public sealed class NextFreeDayHandler : IAdjustmentHandler
{
    public DateOnly? Adjust(AdjustmentHandlerContext context)
    {
        DateOnly date = context.BaseDate;
        while (context.IsOccupied(date))
            date = date.AddDays(1);

        return date == context.BaseDate ? null : date; // null leaves it on the calculated date
    }
}

Remarks

A handler is bound to a policy through the policy's handler key and is consulted during the placement phase, after the actual date has been calculated. It receives the calculated date together with the surrounding resolution context, so it can resolve other rules or test whether candidate days are already claimed by non-working occurrences.

Methods

Adjust(AdjustmentHandlerContext)

Computes the observed date for an occurrence.

DateOnly? Adjust(AdjustmentHandlerContext context)

Parameters

context AdjustmentHandlerContext

The context describing the occurrence being adjusted.

Returns

DateOnly?

The observed date, or null to leave the occurrence on its calculated date.

Applies to

ProductVersions
.NET8, 10

See Also