Interface ICalendar
- Namespace
- Quartz
- Assembly
- Quartz.dll
An interface to be implemented by objects that define spaces of time during which an associated ITrigger may (not) fire. Calendars do not define actual fire times, but rather are used to limit a ITrigger from firing on its normal schedule if necessary. Most Calendars include all times by default and allow the user to specify times to exclude.
public interface ICalendar
Remarks
As such, it is often useful to think of Calendars as being used to exclude a block of time - as opposed to include a block of time. (i.e. the schedule "fire every five minutes except on Sundays" could be implemented with a ISimpleTrigger and a WeeklyCalendar which excludes Sundays)
An implementation of its own has two obligations. It must be properly cloneable, because the
scheduler hands callers Clone()s rather than the stored instance. And, to live in a
persistent store, it needs a
CalendarSerializer<TCalendar> registered with
AddCalendarSerializer — UseSystemTextJsonSerializer(json =>
json.AddCalendarSerializer(new MyCalendarSerializer())). Without one, the first
AddCalendar(string, ICalendar, AddCalendarOptions, CancellationToken) that reaches the store fails while writing it, naming the
calendar's type. [Serializable] is what 3.x asked for and no longer stores anything: 4.x
has no BinaryFormatter.
Properties
CalendarBase
Set a new base calendar or remove the existing one. Get the base calendar.
ICalendar? CalendarBase { get; set; }
Property Value
Description
Gets or sets a description for the ICalendar instance - may be useful for remembering/displaying the purpose of the calendar, though the description has no meaning to Quartz.
string? Description { get; set; }
Property Value
Methods
Clone()
Returns a copy of this calendar that can be changed without changing this one.
ICalendar Clone()
Returns
Remarks
This is what stands between a caller's instance and the one a store holds: a store clones a calendar as it is added and again as it is read back, so an implementation that returned a shared object would let a caller edit stored scheduling data in place. The built-in calendars copy their exclusion sets and clone CalendarBase in turn.
GetNextIncludedTimeUtc(DateTimeOffset)
Determine the next UTC time that is 'included' by the Calendar after the given UTC time.
DateTimeOffset GetNextIncludedTimeUtc(DateTimeOffset timeUtc)
Parameters
timeUtcDateTimeOffset
Returns
IsTimeIncluded(DateTimeOffset)
Determine whether the given UTC time is 'included' by the Calendar.
bool IsTimeIncluded(DateTimeOffset timeUtc)
Parameters
timeUtcDateTimeOffset