} // 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
Пример #2
0
        } // HasOverlaps

        // ----------------------------------------------------------------------
        public virtual bool HasGaps()
        {
            bool hasGaps = false;

            if (Count > 1)
            {
                hasGaps = new TimeLineMomentCollection(this).HasGaps();
            }

            return(hasGaps);
        } // HasGaps
Пример #3
0
        } // InsidePeriods

        // ----------------------------------------------------------------------
        public virtual bool HasOverlaps()
        {
            bool hasOverlaps = false;

            if (Count == 2)
            {
                hasOverlaps = this[0].OverlapsWith(this[1]);
            }
            else if (Count > 2)
            {
                hasOverlaps = new TimeLineMomentCollection(this).HasOverlaps();
            }

            return(hasOverlaps);
        } // HasOverlaps
Пример #4
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