Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
        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));
            }
        }
Exemplo n.º 5
0
 public override string ToString()
 {
     return(BankHolidays == BankHolidayRunning.RunsOnBankHoliday
         ? $"{RunsFrom.ToYMD()}=>{RunsTo.ToYMD()} {DayMask.ToStringEx()}"
         : $"{RunsFrom.ToYMD()}=>{RunsTo.ToYMD()} {DayMask.ToStringEx()} ({BankHolidays.ToStringEx()})");
 }