private static IEnumerable <AppointmentSlot> CreateAppointmentSlots( TimeSlotCollectionView timeSlots, IDateSpan intersection, Func <TimeSlot, AppointmentSlot> slotCreator) { return (from g in timeSlots.Groups let intersected = from slot in g.TimeSlots where intersection.IntersectsWith(slot) select slot where intersected.Count() > 0 select slotCreator(new TimeSlotGroup(intersected))); }
internal static IList <AppointmentSlot> GetAppointmentSlots( this IAppointment appointment, TimeSlotCollectionView timeSlots) { var slots = new List <AppointmentSlot>(); var effectiveRange = new TimeSlotGroup(timeSlots); foreach (Occurrence occurrence in appointment.GetOccurrences(effectiveRange.Start, effectiveRange.End)) { slots.AddRange( CreateAppointmentSlots( timeSlots, occurrence, timeSlot => new AppointmentSlot(occurrence, timeSlot))); } return(slots); }
/// <summary> /// Initializes a new instance of the <see cref="TimeSlotCollectionViewGroupRoot"/> class. /// </summary> /// <param name="collectionView">The collection view.</param> /// <exception cref="ArgumentNullException"><c>collectionView</c> is null.</exception> internal TimeSlotCollectionViewGroupRoot(TimeSlotCollectionView collectionView) { if (collectionView == null) { throw new ArgumentNullException("collectionView"); } this.collectionView = collectionView; this.collectionView.CollectionChanged += this.OnViewCollectionChanged; this.GroupDescriptions = new ObservableCollection <GroupDescription>(); this.GroupDescriptions.CollectionChanged += this.OnGroupDescriptionsCollectionChanged; this.groupsCollection = new ObservableCollection <TimeSlotGroup>(); this.Groups = new ReadOnlyObservableCollection <TimeSlotGroup>(this.groupsCollection); }