コード例 #1
0
            public Period(int period, int month, int year)
            {
                this.period = period;
                this.month  = month;
                this.year   = year;


                int s = (period == 1 ? 1 : 16),
                    e = (period == 1 ? 15 : DateTime.DaysInMonth(year, month));

                for (int c = s; c <= e; c++)
                {
                    switch (new DateTime(year, month, c).DayOfWeek)
                    {
                    case DayOfWeek.Monday: Mon.Add(c); break;

                    case DayOfWeek.Tuesday: Tue.Add(c); break;

                    case DayOfWeek.Wednesday: Wed.Add(c); break;

                    case DayOfWeek.Thursday: Thu.Add(c); break;

                    case DayOfWeek.Friday: Fri.Add(c); break;

                    case DayOfWeek.Saturday: Sat.Add(c); break;

                    case DayOfWeek.Sunday: Sun.Add(c); break;
                    }
                }
            }
コード例 #2
0
        /// <summary>
        /// Returns true if WorkingRestrictionHoursOfWork instances are equal
        /// </summary>
        /// <param name="other">Instance of WorkingRestrictionHoursOfWork to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(WorkingRestrictionHoursOfWork other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Mon == other.Mon ||
                     Mon != null &&
                     Mon.Equals(other.Mon)
                     ) &&
                 (
                     Tue == other.Tue ||
                     Tue != null &&
                     Tue.Equals(other.Tue)
                 ) &&
                 (
                     Wed == other.Wed ||
                     Wed != null &&
                     Wed.Equals(other.Wed)
                 ) &&
                 (
                     Thu == other.Thu ||
                     Thu != null &&
                     Thu.Equals(other.Thu)
                 ) &&
                 (
                     Fri == other.Fri ||
                     Fri != null &&
                     Fri.Equals(other.Fri)
                 ) &&
                 (
                     Sat == other.Sat ||
                     Sat != null &&
                     Sat.Equals(other.Sat)
                 ) &&
                 (
                     Sun == other.Sun ||
                     Sun != null &&
                     Sun.Equals(other.Sun)
                 ));
        }
コード例 #3
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Mon != null)
         {
             hashCode = hashCode * 59 + Mon.GetHashCode();
         }
         if (Tue != null)
         {
             hashCode = hashCode * 59 + Tue.GetHashCode();
         }
         if (Wed != null)
         {
             hashCode = hashCode * 59 + Wed.GetHashCode();
         }
         if (Thu != null)
         {
             hashCode = hashCode * 59 + Thu.GetHashCode();
         }
         if (Fri != null)
         {
             hashCode = hashCode * 59 + Fri.GetHashCode();
         }
         if (Sat != null)
         {
             hashCode = hashCode * 59 + Sat.GetHashCode();
         }
         if (Sun != null)
         {
             hashCode = hashCode * 59 + Sun.GetHashCode();
         }
         return(hashCode);
     }
 }