protected virtual void StartEvaluation()
        {
            if (Periods.Count > 0)
            {
                TimeLineMomentCollection timeLineMoments = new TimeLineMomentCollection();
                timeLineMoments.AddAll(Periods);
                if (timeLineMoments.Count > 1)
                {
                    int periodCount = 0;
                    for (int i = 0; i < timeLineMoments.Count - 1; i++)
                    {
                        ITimeLineMoment start = timeLineMoments[i];
                        ITimeLineMoment end   = timeLineMoments[i + 1];

                        if (i == 0)
                        {
                            periodCount += start.StartCount;
                            periodCount -= start.EndCount;
                        }

                        ITimePeriod period = new TimeRange(MapPeriodStart(start.Moment), MapPeriodEnd(end.Moment));
                        if (!(IgnoreEmptyPeriods && period.IsMoment))
                        {
                            if (EvaluatePeriod(period, periodCount) == false)
                            {
                                break;
                            }
                        }

                        periodCount += end.StartCount;
                        periodCount -= end.EndCount;
                    }
                }
            }
        }
Esempio n. 2
0
        private ITimeLineMomentCollection GetTimeLineMoments(ICollection <ITimePeriod> momentPeriods)
        {
            TimeLineMomentCollection timeLineMoments = new TimeLineMomentCollection();

            if (momentPeriods.Count == 0)
            {
                return(timeLineMoments);
            }

            // setup gap set with all start/end points
            ITimePeriodCollection intersections = new TimePeriodCollection();

            foreach (ITimePeriod momentPeriod in momentPeriods)
            {
                if (momentPeriod.IsMoment)
                {
                    continue;
                }

                // calculate the intersection between the periods
                ITimeRange intersection = _limits.GetIntersection(momentPeriod);
                if (intersection == null || intersection.IsMoment)
                {
                    continue;
                }

                if (PeriodMapper != null)
                {
                    intersection = new TimeRange(MapPeriodStart(intersection.Start), MapPeriodEnd(intersection.End));
                }

                intersections.Add(intersection);
            }

            timeLineMoments.AddAll(intersections);
            return(timeLineMoments);
        }