Beispiel #1
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);
        }