Class BaseCalendar
This implementation of the Calendar may be used (you don't have to) as a base class for more sophisticated one's. It merely implements the base functionality required by each Calendar.
[Serializable]
public class BaseCalendar : ICalendar, ISerializable, IEquatable<BaseCalendar>
- Inheritance
-
BaseCalendar
- Implements
- Derived
- Inherited Members
Remarks
Regarded as base functionality is the treatment of base calendars. Base calendar allow you to chain (stack) as much calendars as you may need. For example to exclude weekends you may use WeeklyCalendar. In order to exclude holidays as well you may define a WeeklyCalendar instance to be the base calendar for HolidayCalendar instance.
Constructors
BaseCalendar()
Initializes a new instance of the BaseCalendar class.
public BaseCalendar()
BaseCalendar(ICalendar?)
Initializes a new instance of the BaseCalendar class.
public BaseCalendar(ICalendar? baseCalendar)
Parameters
baseCalendarICalendarThe base calendar.
BaseCalendar(ICalendar?, TimeZoneInfo?)
Initializes a new instance of the BaseCalendar class.
public BaseCalendar(ICalendar? baseCalendar, TimeZoneInfo? timeZone)
Parameters
baseCalendarICalendarThe base calendar.
timeZoneTimeZoneInfoThe time zone.
BaseCalendar(SerializationInfo, StreamingContext)
Serialization constructor.
protected BaseCalendar(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfocontextStreamingContext
BaseCalendar(TimeZoneInfo)
Initializes a new instance of the BaseCalendar class.
public BaseCalendar(TimeZoneInfo timeZone)
Parameters
timeZoneTimeZoneInfoThe time zone.
Properties
CalendarBase
Set a new base calendar or remove the existing one
public ICalendar? CalendarBase { get; set; }
Property Value
Description
Gets or sets the description given to the ICalendar instance by its creator (if any).
public string? Description { get; set; }
Property Value
TimeZone
Gets or sets the time zone.
public virtual TimeZoneInfo TimeZone { get; set; }
Property Value
- TimeZoneInfo
The time zone.
Methods
Clone()
Creates a new object that is a copy of the current instance.
public virtual ICalendar Clone()
Returns
- ICalendar
A new object that is a copy of this instance.
CloneFields(BaseCalendar)
Copies the fields every calendar has — description, time zone and base calendar — into a copy a derived type has constructed, which then copies its own.
protected BaseCalendar CloneFields(BaseCalendar clone)
Parameters
cloneBaseCalendarThe copy being built.
Returns
- BaseCalendar
The same copy, so that an override can return it directly.
Equals(BaseCalendar?)
Whether this calendar and other exclude the same times.
public bool Equals(BaseCalendar? other)
Parameters
otherBaseCalendarThe calendar to compare with.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
[SuppressMessage("Sonar", "S2328:GetHashCode should not reference mutable fields", Justification = "Content equality over mutable state is what a calendar is; see the remarks.")]
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Remarks
The hash is over the same mutable state Equals(BaseCalendar?) compares, which is what the two members have to agree on, and every calendar in this namespace is the same shape. A calendar is an editable description of excluded time — Description, the time zone, the excluded days — and the alternative to hashing it is a constant, which puts every calendar in one bucket and answers nothing. Nothing in Quartz keys a hash-based collection by a calendar instance: the stores hold calendars by name, and the name is a string.
GetNextIncludedTimeUtc(DateTimeOffset)
Determine the next UTC time (in milliseconds) that is 'included' by the Calendar after the given time. Return the original value if timeStamp is included. Return 0 if all days are excluded.
public virtual DateTimeOffset GetNextIncludedTimeUtc(DateTimeOffset timeUtc)
Parameters
timeUtcDateTimeOffset
Returns
- See Also
GetObjectData(SerializationInfo, StreamingContext)
Writes this calendar's fields into a serialization payload.
[SecurityCritical]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoThe payload being written.
contextStreamingContextThe serialization context.
IsTimeIncluded(DateTimeOffset)
Check if date/time represented by timeStamp is included. If included return true. The implementation of BaseCalendar simply calls the base calendars IsTimeIncluded() method if base calendar is set.
public virtual bool IsTimeIncluded(DateTimeOffset timeStampUtc)
Parameters
timeStampUtcDateTimeOffset
Returns
- See Also