WorkingDaysOfWeekExtensions Class
Definition
Provides bidirectional conversion between the WorkingDaysOfWeek enum sugar and the WeekPattern value type.
public static class WorkingDaysOfWeekExtensions
- Inheritance
-
WorkingDaysOfWeekExtensions
- Inherited Members
Methods
ToWeekPattern(WorkingDaysOfWeek)
Returns the canonical WeekPattern for the supplied WorkingDaysOfWeek value.
public static WeekPattern ToWeekPattern(this WorkingDaysOfWeek value)
Parameters
valueWorkingDaysOfWeekThe named working-week pattern to convert.
Returns
- WeekPattern
The WeekPattern whose selected days match
value.
Exceptions
- ArgumentOutOfRangeException
Thrown when
valueis not a defined member of the WorkingDaysOfWeek enumeration.- ArgumentException
Thrown when
valueis Custom, which has no canonical pattern.
ToWeekPattern(WorkingDaysOfWeek, IWeekendDefinitionProvider?)
Returns the canonical WeekPattern for the supplied WorkingDaysOfWeek value,
consulting provider when value is
Custom.
public static WeekPattern ToWeekPattern(this WorkingDaysOfWeek value, IWeekendDefinitionProvider? provider)
Parameters
valueWorkingDaysOfWeekThe named working-week pattern to convert.
providerIWeekendDefinitionProviderA custom weekend provider consulted only when
valueis Custom.
Returns
- WeekPattern
The WeekPattern whose selected days match the working-week implied by
value(andproviderwhen applicable).
Exceptions
- ArgumentOutOfRangeException
Thrown when
valueis not a defined member of the WorkingDaysOfWeek enumeration.- ArgumentNullException
ToWorkingDaysOfWeek(WeekPattern)
Returns the matching WorkingDaysOfWeek value for the supplied WeekPattern, or Custom when no named preset matches.
public static WorkingDaysOfWeek ToWorkingDaysOfWeek(this WeekPattern pattern)
Parameters
patternWeekPatternThe pattern to identify.
Returns
- WorkingDaysOfWeek
The WorkingDaysOfWeek whose canonical pattern equals
pattern, or Custom whenpatterndoes not match any named preset.
TryGetWorkingDaysOfWeek(WeekPattern, out WorkingDaysOfWeek)
Attempts to identify the supplied WeekPattern as a named WorkingDaysOfWeek preset.
public static bool TryGetWorkingDaysOfWeek(this WeekPattern pattern, out WorkingDaysOfWeek value)
Parameters
patternWeekPatternThe pattern to identify.
valueWorkingDaysOfWeekWhen this method returns true, contains the matching WorkingDaysOfWeek; otherwise, Custom.
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |