コード例 #1
1
        /// <summary>
        /// Determines the number of days from one DayOfWeek till the next.
        /// </summary>
        /// <param name="self">the starting DayOfWeek</param>
        /// <param name="next">The ending DayOfWeek</param>
        /// <returns>the number of days from <paramref name="self"/> to <paramref name="next"/></returns>
        /// <exception cref="ArgumentOutOfRangeException">If either DayOfWeek is not 
        /// <see cref="DayOfWeekExtensions.InRange"/></exception>
        /// <example>
        /// Debug.Assert(DayOfWeek.Monday.DaysTill(DayOfWeek.Tuesday) == 1);
        /// </example>
        public static int DaysTill(this DayOfWeek self, DayOfWeek next)
        {
            self.CheckRange();
            next.CheckRange();

            return DaysBetween((int)next, (int)self);
        }
 public static void Validate(this IConstrainedString val, string arg)
 {
     if (val == null || !val.CheckRange())
     {
         throw new ArgumentException(arg);
     }
 }
コード例 #3
0
        /// <summary>
        /// Determines the number of days since one DayOfWeek since the previous.
        /// </summary>
        /// <param name="self">the starting DayOfWeek</param>
        /// <param name="prev">The previous DayOfWeek</param>
        /// <returns>the number of days since <paramref name="self"/> to <paramref name="prev"/></returns>
        /// <exception cref="ArgumentOutOfRangeException">If either DayOfWeek is not 
        /// <see cref="DayOfWeekExtensions.InRange"/></exception>
        /// <example>
        /// Debug.Assert(DayOfWeek.Tuesday.DaysSince(DayOfWeek.Monday) == 1);
        /// </example>
        public static int DaysSince(this DayOfWeek self, DayOfWeek prev)
        {
            self.CheckRange();
            prev.CheckRange();

            return DaysBetween((int)self, (int)prev);
        }