Exemplo n.º 1
0
        }         // IgnoreEmptyPeriods

        // ----------------------------------------------------------------------
        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;
                    }
                }
            }
        }         // StartEvaluation
Exemplo n.º 2
0
        }         // GetTimeLineMoments

        // ----------------------------------------------------------------------
        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);
        }         // GetTimeLineMoments