Class AbstractTimeInterval
- Namespace
- Core.CliniCore.Scheduling
- Assembly
- Core.CliniCore.dll
Base implementation for all time interval types
public abstract class AbstractTimeInterval : ITimeInterval, IIdentifiable
- Inheritance
-
AbstractTimeInterval
- Implements
- Derived
- Inherited Members
Constructors
AbstractTimeInterval(DateTime, DateTime, string)
protected AbstractTimeInterval(DateTime start, DateTime end, string description = "")
Parameters
Properties
DayOfWeek
Gets the day of week for this interval
public DayOfWeek DayOfWeek { get; }
Property Value
Description
Description or title of this time interval
public virtual string Description { get; protected set; }
Property Value
Duration
Duration of the interval
public TimeSpan Duration { get; }
Property Value
End
End time of the interval
public DateTime End { get; protected set; }
Property Value
Id
Unique identifier for this time interval
public Guid Id { get; protected set; }
Property Value
Start
Start time of the interval
public DateTime Start { get; protected set; }
Property Value
Methods
Contains(ITimeInterval)
Checks if this interval completely contains another interval
public virtual bool Contains(ITimeInterval other)
Parameters
otherITimeInterval
Returns
Contains(DateTime)
Checks if this interval contains a specific point in time
public virtual bool Contains(DateTime moment)
Parameters
momentDateTime
Returns
CreateMergedInterval(DateTime, DateTime, string, ITimeInterval)
Override in derived classes to create a properly typed merged interval
protected abstract ITimeInterval? CreateMergedInterval(DateTime start, DateTime end, string description, ITimeInterval other)
Parameters
startDateTimeendDateTimedescriptionstringotherITimeInterval
Returns
Equals(object?)
Equality comparison
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
Hash code for dictionary storage
public override int GetHashCode()
Returns
GetSpecificValidationErrors()
Override in derived classes to add specific validation rules
protected virtual List<string> GetSpecificValidationErrors()
Returns
GetValidationErrors()
Gets validation errors if the interval is not valid
public virtual List<string> GetValidationErrors()
Returns
IsAdjacentTo(ITimeInterval)
Checks if this interval is adjacent to another (touching but not overlapping)
public virtual bool IsAdjacentTo(ITimeInterval other)
Parameters
otherITimeInterval
Returns
IsBusinessHoursSlot(DateTime, DateTime)
Static helper to check if a given time slot is available
public static bool IsBusinessHoursSlot(DateTime start, DateTime end)
Parameters
Returns
IsValid()
Validates that the interval is valid
public virtual bool IsValid()
Returns
IsWithinBusinessHours()
Checks if this interval occurs within business hours (M-F 8am-5pm)
public virtual bool IsWithinBusinessHours()
Returns
MergeWith(ITimeInterval)
Attempts to merge with another interval if they overlap or are adjacent
public virtual ITimeInterval? MergeWith(ITimeInterval other)
Parameters
otherITimeInterval
Returns
Overlaps(ITimeInterval)
Checks if this interval overlaps with another
public virtual bool Overlaps(ITimeInterval other)
Parameters
otherITimeInterval
Returns
ToString()
Gets a display string for this interval
public override string ToString()