Table of Contents

NotableDateDefinitionBuilder Class

Definition

Namespace
Bodu.Globalization.Calendar.Builder
Assembly
Bodu.Globalization.Calendar.Builder.dll
Package
Bodu.Globalization.Calendar.Builder 1.0.0
Source
NotableDateDefinitionBuilder.cs

Provides a fluent surface for authoring a notable-date concept: its identity, default category, duration and non-working flags, concept-level tags, and one or more calculation rules.

public sealed class NotableDateDefinitionBuilder
Inheritance
NotableDateDefinitionBuilder
Inherited Members
Extension Methods

Examples

document.AddNotableDate("anzac-day", "Anzac Day", NotableDateCategory.PublicHoliday, c => c
    .AsNonWorkingByDefault()
    .AddTag("Remembrance")
    .AddRule("au", r => r.ForTerritory("AU").Fixed(4, 25))
    .AddRule("nz", r => r.ForTerritory("NZ").Fixed(4, 25)));

Remarks

A concept groups the rules that express the same notable date across territories or eras - for example a national rule and a regional variant that calculate the same holiday differently. Set concept-level defaults (category, duration, non-working) once, then add each variant with AddRule(string, Action<NotableDateRuleBuilder>); a rule may override the defaults it needs to. Configure the builder inside AddNotableDate(string, string, NotableDateCategory, Action<NotableDateDefinitionBuilder>) .

Methods

AddRule(string, Action<NotableDateRuleBuilder>)

Adds a rule to the concept and configures it through the supplied delegate.

public NotableDateDefinitionBuilder AddRule(string id, Action<NotableDateRuleBuilder> configure)

Parameters

id string

The stable identifier of the rule within the concept.

configure Action<NotableDateRuleBuilder>

A delegate that configures the rule.

Returns

NotableDateDefinitionBuilder

The same NotableDateDefinitionBuilder instance, enabling chained calls.

Exceptions

ArgumentException

id is null, empty, or white-space.

ArgumentNullException

configure is null.

AddTag(string)

Adds a single tag to the concept.

public NotableDateDefinitionBuilder AddTag(string tag)

Parameters

tag string

The tag value.

Returns

NotableDateDefinitionBuilder

The same NotableDateDefinitionBuilder instance, enabling chained calls.

Exceptions

ArgumentException

tag is null, empty, or white-space.

AsNonWorkingByDefault(bool)

Sets whether occurrences of the concept are non-working days by default.

public NotableDateDefinitionBuilder AsNonWorkingByDefault(bool value = true)

Parameters

value bool

The default non-working flag.

Returns

NotableDateDefinitionBuilder

The same NotableDateDefinitionBuilder instance, enabling chained calls.

WithCategory(NotableDateCategory)

Sets the category of the concept.

public NotableDateDefinitionBuilder WithCategory(NotableDateCategory category)

Parameters

category NotableDateCategory

The category.

Returns

NotableDateDefinitionBuilder

The same NotableDateDefinitionBuilder instance, enabling chained calls.

WithDefaultDurationDays(int)

Sets the default duration in days for occurrences of the concept.

public NotableDateDefinitionBuilder WithDefaultDurationDays(int days)

Parameters

days int

The default duration in days.

Returns

NotableDateDefinitionBuilder

The same NotableDateDefinitionBuilder instance, enabling chained calls.

Exceptions

ArgumentOutOfRangeException

days is less than 1.

WithDisplayName(string)

Sets the human-readable display name of the concept.

public NotableDateDefinitionBuilder WithDisplayName(string displayName)

Parameters

displayName string

The display name.

Returns

NotableDateDefinitionBuilder

The same NotableDateDefinitionBuilder instance, enabling chained calls.

Exceptions

ArgumentException

displayName is null, empty, or white-space.

WithTags(params string[])

Replaces the concept's tags with the supplied collection.

public NotableDateDefinitionBuilder WithTags(params string[] tags)

Parameters

tags string[]

The tag values.

Returns

NotableDateDefinitionBuilder

The same NotableDateDefinitionBuilder instance, enabling chained calls.

Exceptions

ArgumentNullException

tags is null.

Applies to

ProductVersions
.NET8, 10

See Also