NotableDateFilter Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.dll
- Package
- Bodu.Globalization.Calendar 1.0.1
- Source
- NotableDateFilter.cs
Represents a composable predicate over resolved NotableDate occurrences, used to restrict the results returned by INotableDateService to those matching a category, tag, name, duration, or observed-state criterion. This class cannot be inherited.
public sealed class NotableDateFilter
- Inheritance
-
NotableDateFilter
- Inherited Members
- Extension Methods
Examples
INotableDateService service = AmericasCalendarData.CreateService("US");
DateRange year = new(new DateOnly(2026, 1, 1), new DateOnly(2026, 12, 31));
// Non-working public holidays only.
NotableDateFilter publicHolidays = NotableDateFilter
.ForCategory(NotableDateCategory.PublicHoliday)
.And(NotableDateFilter.IsNonWorkingDay());
IReadOnlyList<NotableDate> holidays = service.Resolve(year, "US", publicHolidays);
// Religious or cultural dates tagged "Christian", excluding observed substitutes.
NotableDateFilter christian = NotableDateFilter
.ForAnyCategory(NotableDateCategory.Religious, NotableDateCategory.Cultural)
.And(NotableDateFilter.WithTag("Christian"))
.And(NotableDateFilter.WasAdjusted().Not());
IReadOnlyList<NotableDate> observances = service.Resolve(year, "US", christian);
Remarks
Construction. A filter is created through the static factory methods on this class - for example ForCategory(NotableDateCategory), WithTag(string), IsNonWorkingDay(), and InDateRange(DateOnly, DateOnly). There is no public constructor; every factory returns an immutable instance.
Composition. Filters combine through the instance operators And(NotableDateFilter), Or(NotableDateFilter), and Not(), and the variadic factories AllOf(params NotableDateFilter[]) and AnyOf(params NotableDateFilter[]). Because every instance is immutable, composition always produces a new filter and never mutates an operand, so a filter can be cached and reused across queries and threads.
Evaluation. A filter is evaluated against each materialized occurrence after resolution: pass a
filter to one of the Resolve overloads on INotableDateService (which keeps only the
occurrences for which Matches(NotableDate) returns true), or call
Matches(NotableDate) directly to test a single occurrence.
Methods
AllOf(params NotableDateFilter[])
Creates a filter that matches an occurrence only when every supplied filter matches it.
public static NotableDateFilter AllOf(params NotableDateFilter[] filters)
Parameters
filtersNotableDateFilter[]The filters that must all match.
Returns
- NotableDateFilter
A filter matching the conjunction of the supplied filters.
Exceptions
- ArgumentNullException
filtersis null.
And(NotableDateFilter)
Combines this filter with another so that both must match.
public NotableDateFilter And(NotableDateFilter other)
Parameters
otherNotableDateFilterThe filter to combine with.
Returns
- NotableDateFilter
A filter matching the conjunction of the two filters.
Exceptions
- ArgumentNullException
otheris null.
AnyOf(params NotableDateFilter[])
Creates a filter that matches an occurrence when any supplied filter matches it.
public static NotableDateFilter AnyOf(params NotableDateFilter[] filters)
Parameters
filtersNotableDateFilter[]The filters, any of which may match.
Returns
- NotableDateFilter
A filter matching the disjunction of the supplied filters.
Exceptions
- ArgumentNullException
filtersis null.
ForAnyCategory(params NotableDateCategory[])
Creates a filter that matches occurrences belonging to any of the supplied categories.
public static NotableDateFilter ForAnyCategory(params NotableDateCategory[] categories)
Parameters
categoriesNotableDateCategory[]The categories to match.
Returns
- NotableDateFilter
A filter matching any of the categories.
Exceptions
- ArgumentNullException
categoriesis null.
ForCategory(NotableDateCategory)
Creates a filter that matches occurrences of a specific category.
public static NotableDateFilter ForCategory(NotableDateCategory category)
Parameters
categoryNotableDateCategoryThe category to match.
Returns
- NotableDateFilter
A filter matching the category.
InDateRange(DateOnly, DateOnly)
Creates a filter that matches occurrences whose emitted date falls within an inclusive date range.
public static NotableDateFilter InDateRange(DateOnly startInclusive, DateOnly endInclusive)
Parameters
Returns
- NotableDateFilter
A filter matching occurrences within the range.
IsNonWorkingDay()
Creates a filter that matches occurrences flagged as non-working days.
public static NotableDateFilter IsNonWorkingDay()
Returns
- NotableDateFilter
A filter matching non-working occurrences.
Matches(NotableDate)
Determines whether the supplied occurrence satisfies the filter.
public bool Matches(NotableDate notableDate)
Parameters
notableDateNotableDateThe resolved occurrence to test.
Returns
Exceptions
- ArgumentNullException
notableDateis null.
Not()
Negates this filter.
public NotableDateFilter Not()
Returns
- NotableDateFilter
A filter matching exactly the occurrences this filter does not.
Or(NotableDateFilter)
Combines this filter with another so that either may match.
public NotableDateFilter Or(NotableDateFilter other)
Parameters
otherNotableDateFilterThe filter to combine with.
Returns
- NotableDateFilter
A filter matching the disjunction of the two filters.
Exceptions
- ArgumentNullException
otheris null.
WasAdjusted()
Creates a filter that matches occurrences whose emitted date differs from the calculated date because an adjustment applied.
public static NotableDateFilter WasAdjusted()
Returns
- NotableDateFilter
A filter matching observed (adjusted) occurrences.
WithAllTags(params string[])
Creates a filter that matches occurrences carrying all of the supplied tags.
public static NotableDateFilter WithAllTags(params string[] tags)
Parameters
tagsstring[]The tags that must all be present.
Returns
- NotableDateFilter
A filter matching occurrences with every tag.
Exceptions
- ArgumentNullException
tagsis null.
WithAnyName(params string[])
Creates a filter that matches occurrences whose display name equals any of the supplied names.
public static NotableDateFilter WithAnyName(params string[] displayNames)
Parameters
displayNamesstring[]The display names to match.
Returns
- NotableDateFilter
A filter matching any of the names.
Exceptions
- ArgumentNullException
displayNamesis null.
WithAnyTag(params string[])
Creates a filter that matches occurrences carrying any of the supplied tags.
public static NotableDateFilter WithAnyTag(params string[] tags)
Parameters
tagsstring[]The tags to match.
Returns
- NotableDateFilter
A filter matching occurrences with any of the tags.
Exceptions
- ArgumentNullException
tagsis null.
WithId(string)
Creates a filter that matches occurrences produced by a specific notable-date concept identifier.
public static NotableDateFilter WithId(string notableDateId)
Parameters
notableDateIdstringThe notable-date concept identifier to match.
Returns
- NotableDateFilter
A filter matching the concept identifier.
Exceptions
- ArgumentNullException
notableDateIdis null.
WithMinDuration(int)
Creates a filter that matches occurrences spanning at least the supplied number of days.
public static NotableDateFilter WithMinDuration(int days)
Parameters
daysintThe minimum inclusive duration in days.
Returns
- NotableDateFilter
A filter matching occurrences of at least the duration.
WithName(string)
Creates a filter that matches occurrences with a specific display name.
public static NotableDateFilter WithName(string displayName)
Parameters
displayNamestringThe display name to match.
Returns
- NotableDateFilter
A filter matching the display name.
Exceptions
- ArgumentNullException
displayNameis null.
WithTag(string)
Creates a filter that matches occurrences carrying a specific tag.
public static NotableDateFilter WithTag(string tag)
Parameters
tagstringThe tag to match.
Returns
- NotableDateFilter
A filter matching occurrences with the tag.
Exceptions
- ArgumentNullException
tagis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |