NotableDateDefinitionBuilder Class
Definition
- Namespace
- Bodu.Globalization.Calendar.Builder
- Assembly
- Bodu.Globalization.Calendar.Builder.dll
- Package
- Bodu.Globalization.Calendar.Builder 1.0.0
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
idstringThe stable identifier of the rule within the concept.
configureAction<NotableDateRuleBuilder>A delegate that configures the rule.
Returns
- NotableDateDefinitionBuilder
The same NotableDateDefinitionBuilder instance, enabling chained calls.
Exceptions
- ArgumentException
idis null, empty, or white-space.- ArgumentNullException
configureis null.
AddTag(string)
Adds a single tag to the concept.
public NotableDateDefinitionBuilder AddTag(string tag)
Parameters
tagstringThe tag value.
Returns
- NotableDateDefinitionBuilder
The same NotableDateDefinitionBuilder instance, enabling chained calls.
Exceptions
- ArgumentException
tagis 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
valueboolThe 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
categoryNotableDateCategoryThe 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
daysintThe default duration in days.
Returns
- NotableDateDefinitionBuilder
The same NotableDateDefinitionBuilder instance, enabling chained calls.
Exceptions
- ArgumentOutOfRangeException
daysis less than 1.
WithDisplayName(string)
Sets the human-readable display name of the concept.
public NotableDateDefinitionBuilder WithDisplayName(string displayName)
Parameters
displayNamestringThe display name.
Returns
- NotableDateDefinitionBuilder
The same NotableDateDefinitionBuilder instance, enabling chained calls.
Exceptions
- ArgumentException
displayNameis null, empty, or white-space.
WithTags(params string[])
Replaces the concept's tags with the supplied collection.
public NotableDateDefinitionBuilder WithTags(params string[] tags)
Parameters
tagsstring[]The tag values.
Returns
- NotableDateDefinitionBuilder
The same NotableDateDefinitionBuilder instance, enabling chained calls.
Exceptions
- ArgumentNullException
tagsis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |