示例#1
0
 public void AddTimeSpan(TimeSpan ts)
 {
     if (!ContainsTimeSpan(ts))
     {
         ReminderTimeSpanTicks.Add(ts.Ticks);
     }
     CheckExpiredTimeSpan();
 }
示例#2
0
        /// <summary>
        /// Checks our list of timespans and returns the
        /// most recently expired timespan
        /// Removes any expired timespans
        /// </summary>
        /// <param name="ts"></param>
        /// <returns></returns>
        public TimeSpan?CheckExpiredTimeSpan()
        {
            TimeSpan?mostRecentlyExpired = null;

            // sort our timespans
            // (probably doesn't matter)
            ReminderTimeSpanTicks.Sort();

            List <TimeSpan> toRemove = new List <TimeSpan>();

            // loop through
            foreach (TimeSpan ts in ReminderTimeSpans)
            {
                // work with expired
                if (IsTimeSpanExpired(ts))
                {
                    // find the most expired one
                    if (mostRecentlyExpired.HasValue)
                    {
                        mostRecentlyExpired = GetMoreRecentlyExpired(mostRecentlyExpired.Value, ts);
                    }
                    else
                    {
                        mostRecentlyExpired = ts;
                    }
                    // remove expired
                    toRemove.Add(ts);
                }
            }

            // remove our timespans that expired
            foreach (TimeSpan ts in toRemove)
            {
                ReminderTimeSpanTicks.Remove(ts.Ticks);
            }

            return(mostRecentlyExpired);
        }
示例#3
0
 public void RemoveTimeSpan(TimeSpan ts)
 {
     ReminderTimeSpanTicks.Remove(ts.Ticks);
 }
示例#4
0
 public bool ContainsTimeSpan(TimeSpan ts)
 {
     return(ReminderTimeSpanTicks.Contains(ts.Ticks));
 }