Пример #1
0
        protected override bool OnVisitDay(DayRange day, DaySeekerContext context)
        {
            day.ShouldNotBeNull("dayRange");

            if (context.IsFinished)
            {
                return(false);
            }

            if (day.IsSamePeriod(context.StartDay))
            {
                return(true);
            }

            if (IsMatchingDay(day, context) == false)
            {
                return(true);
            }

            if (CheckLimits(day) == false)
            {
                return(true);
            }

            context.ProcessDay(day);

            // context가 찾기를 완료하면, Visit를 중단하도록 합니다.
            return(!context.IsFinished);
        }
Пример #2
0
        public DaySeekerContext(DayRange startDay, int dayCount)
        {
            startDay.ShouldNotBeNull("startDay");

            StartDay    = startDay;
            DayCount    = Math.Abs(dayCount);
            RemaingDays = DayCount;
        }
Пример #3
0
        protected DayRange StartDayVisit(DayRange day, TContext context, SeekDirection?visitDirection = null)
        {
            day.ShouldNotBeNull("day");
            var direction = visitDirection ?? SeekDirection;

            if (IsDebugEnabled)
            {
                log.Debug("Day 단위로 탐색합니다. day=[{0}], context=[{1}], direction=[{2}]", day, context, direction);
            }

            DayRange lastVisited = null;

            OnVisitStart();

            var minStart = DateTime.MinValue;
            var maxEnd   = DateTime.MaxValue.AddYears(-1);
            var offset   = (direction == SeekDirection.Forward) ? 1 : -1;

            while (day.Start > minStart && day.End < maxEnd)
            {
                if (OnVisitDay(day, context) == false)
                {
                    lastVisited = day;
                    break;
                }

                day = day.AddDays(offset);
            }

            OnVisitEnd();

            if (IsDebugEnabled)
            {
                log.Debug("마지막 탐색 Day. lastVisited=[{0}]", lastVisited);
            }

            return(lastVisited);
        }