Ejemplo n.º 1
0
        /// <summary>
        /// Returns all occurrences of components of type T that start within the date range provided.
        /// All components occurring between <paramref name="startTime"/> and <paramref name="endTime"/>
        /// will be returned.
        /// </summary>
        /// <param name="startTime">The starting date range</param>
        /// <param name="endTime">The ending date range</param>
        public virtual HashSet <Occurrence> GetOccurrences <T>(IDateTime startTime, IDateTime endTime) where T : IRecurringComponent
        {
            var occurrences = new HashSet <Occurrence>(RecurringItems.OfType <T>().SelectMany(recurrable => recurrable.GetOccurrences(startTime, endTime)));

            occurrences.ExceptWith(
                occurrences.Where(o => o.Source is IUniqueComponent)
                .Where(o => o.Source.RecurrenceId != null)
                .Where(o => o.Source.RecurrenceId.Equals(o.Period.StartTime)));

            return(occurrences);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns all occurrences of components of type T that start within the date range provided.
        /// All components occurring between <paramref name="startTime"/> and <paramref name="endTime"/>
        /// will be returned.
        /// </summary>
        /// <param name="startTime">The starting date range</param>
        /// <param name="endTime">The ending date range</param>
        public virtual HashSet <Occurrence> GetOccurrences <T>(IDateTime startTime, IDateTime endTime) where T : IRecurringComponent
        {
            var occurrences = new HashSet <Occurrence>(RecurringItems
                                                       .OfType <T>()
                                                       .SelectMany(recurrable => recurrable.GetOccurrences(startTime, endTime)));

            var removeOccurrencesQuery = occurrences
                                         .Where(o => o.Source is UniqueComponent)
                                         .GroupBy(o => ((UniqueComponent)o.Source).Uid)
                                         .SelectMany(group => group
                                                     .Where(o => o.Source.RecurrenceId != null)
                                                     .SelectMany(occurrence => group.
                                                                 Where(o => o.Source.RecurrenceId == null && occurrence.Source.RecurrenceId.Date.Equals(o.Period.StartTime.Date))));

            occurrences.ExceptWith(removeOccurrencesQuery);
            return(occurrences);
        }