Ejemplo n.º 1
0
        /// <summary>
        /// "Flattens" component recurrences that occur in the given date into a series of equivalent objects.
        /// </summary>
        /// <param name="dt">The date on which the event recurs</param>
        /// <returns>A list of <see cref="Event"/>s if they could be flattened, null otherwise.</returns>
        virtual public IEnumerable <RecurringComponent> FlattenRecurrencesOn(Date_Time dt)
        {
            // Create a dummy iCalendar to hold our flattened component
            iCalendar iCal = new iCalendar();

            if (Start.TZID != null)
            {
                // Place the time zone into our dummy iCalendar
                DDay.iCal.Components.TimeZone tz = iCalendar.GetTimeZone(Start.TZID);
                if (tz != null)
                {
                    tz.Copy(iCal);
                }
            }

            // Iterate through each period to find all occurrences on this date
            foreach (Period p in Periods)
            {
                // Check to see if this occurrence is on the same date
                if (p.StartTime.Date.Equals(dt.Date))
                {
                    // Copy the component into the dummy iCalendar
                    RecurringComponent rc = (RecurringComponent)Copy(iCal);

                    rc.Start  = p.StartTime.Copy();
                    rc.RRule  = new Recur[0];
                    rc.RDate  = new RDate[0];
                    rc.ExRule = new Recur[0];
                    rc.ExDate = new RDate[0];

                    yield return(rc);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// "Flattens" component recurrences into a series of equivalent objects.
        /// </summary>
        /// <returns>A list of <see cref="Event"/>s if they could be flattened, null otherwise.</returns>
        virtual public IEnumerable <RecurringComponent> FlattenRecurrences()
        {
            // Create a dummy iCalendar to hold our flattened component
            iCalendar iCal = new iCalendar();

            if (Start.TZID != null)
            {
                // Place the time zone into our dummy iCalendar
                DDay.iCal.Components.TimeZone tz = iCalendar.GetTimeZone(Start.TZID);
                if (tz != null)
                {
                    tz.Copy(iCal);
                }
            }

            // Iterate through each period to find all occurrences on this date
            foreach (Period p in Periods)
            {
                yield return(FlattenInstance(iCal, p));
            }
        }