public int CompareTo(CifCalendar other) { if (ReferenceEquals(null, other)) { return(-1); } var compare = RunsFrom.CompareTo(other.RunsFrom); if (compare != 0) { return(compare); } compare = RunsTo.CompareTo(other.RunsTo); if (compare != 0) { return(compare); } compare = DayMask.CompareTo(other.DayMask); if (compare != 0) { return(compare); } return(BankHolidays.CompareTo(other.BankHolidays)); }
public override int GetHashCode() { unchecked { var hashCode = RunsFrom.GetHashCode(); hashCode = (hashCode * 397) ^ RunsTo.GetHashCode(); hashCode = (hashCode * 397) ^ (int)DayMask; hashCode = (hashCode * 397) ^ (int)BankHolidays; return(hashCode); } }
public bool Equals(CifCalendar other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(RunsFrom.Equals(other.RunsFrom) && RunsTo.Equals(other.RunsTo) && DayMask == other.DayMask && BankHolidays == other.BankHolidays); }
public void Generate() { // Make idempotent, don't regenerate mask if (_calendarMask != null) { return; } var days = (int)((RunsTo.Date - RunsFrom.Date).TotalDays) + 1; if (days <= 0) { throw new ArgumentOutOfRangeException($"Negative calendar range {nameof(RunsFrom)} > {nameof(RunsTo)}"); } _calendarMask = new BitArray(days); for (int i = 0; i < days; i++) { _calendarMask[i] = IsActiveOnDay(RunsFrom.AddDays(i)); } }
public override string ToString() { return(BankHolidays == BankHolidayRunning.RunsOnBankHoliday ? $"{RunsFrom.ToYMD()}=>{RunsTo.ToYMD()} {DayMask.ToStringEx()}" : $"{RunsFrom.ToYMD()}=>{RunsTo.ToYMD()} {DayMask.ToStringEx()} ({BankHolidays.ToStringEx()})"); }