Пример #1
0
 /// <summary>
 /// Custom comparator method that compares two dates, all parameters
 /// into account. Use MatchesWithShallow(SavedTime)
 /// for a shallow compare.
 /// </summary>
 /// <param name="dateToCompare">Other date to compare to</param>
 /// <returns>True if they match</returns>
 public bool MatchesWithDeep(SavedTime dateToCompare)
 {
     return
         (Year == dateToCompare.Year &&
          Month == dateToCompare.Month &&
          WeekDay == dateToCompare.WeekDay &&
          Day == dateToCompare.Day &&
          Hours24 == dateToCompare.Hours24 &&
          Minutes == dateToCompare.Minutes &&
          Seconds == dateToCompare.Seconds &&
          DayPhase == dateToCompare.DayPhase);
 }
Пример #2
0
        /// <summary>
        /// Custom comparator method that compares two dates, taking only the
        /// assigned parameters into account. Use MatchesWithDeep(SavedTime)
        /// for a deep compare.
        /// </summary>
        /// <param name="dateToCompare">Other date to compare to</param>
        /// <returns>True if they match</returns>
        public bool MatchesWithShallow(SavedTime dateToCompare)
        {
            // Prevent further actions if there is one without parameters
            if (NoParameters || dateToCompare.NoParameters)
            {
                return(true);
            }

            // Check Year
            if (this.Year != null && dateToCompare.Year != null)
            {
                if (this.Year != dateToCompare.Year)
                {
                    return(false);
                }
            }

            // Check Month
            if (this.Month != null && dateToCompare.Month != null)
            {
                if (this.Month != dateToCompare.Month)
                {
                    return(false);
                }
            }

            // Check Weekday
            if (this.WeekDay != null && dateToCompare.WeekDay != null)
            {
                if (this.WeekDay != dateToCompare.WeekDay)
                {
                    return(false);
                }
            }

            // Check Day
            if (this.Day != null && dateToCompare.Day != null)
            {
                if (this.Day != dateToCompare.Day)
                {
                    return(false);
                }
            }

            // Check Dayphase
            if (this.DayPhase != null && dateToCompare.DayPhase != null)
            {
                if (this.DayPhase != dateToCompare.DayPhase)
                {
                    return(false);
                }
            }

            // Check Hours
            if (this.Hours24 != null && dateToCompare.Hours24 != null)
            {
                if (this.Hours24 != dateToCompare.Hours24)
                {
                    return(false);
                }
            }

            // Check Minutes
            if (this.Minutes != null && dateToCompare.Minutes != null)
            {
                if (this.Minutes != dateToCompare.Minutes)
                {
                    return(false);
                }
            }

            // Check Seconds
            if (this.Seconds != null && dateToCompare.Seconds != null)
            {
                if (this.Seconds != dateToCompare.Seconds)
                {
                    return(false);
                }
            }

            // If we get here, the dates are considered the same
            return(true);
        }