// ---------------------------------------------------------------------- public TargetMomentCalculator( ITimePeriodContainer periods, TimeSpan duration ) : base(periods) { if ( duration == null ) { throw new ArgumentNullException( "duration" ); } this.duration = duration; }
// ---------------------------------------------------------------------- protected TimeLinePeriodEvaluator( ITimePeriodContainer periods, ITimePeriodMapper periodMapper = null ) { if ( periods == null ) { throw new ArgumentNullException( "periods" ); } this.periods = periods; this.periodMapper = periodMapper; }
} // PeriodMapper // ---------------------------------------------------------------------- public virtual ITimePeriodCollection IntersectPeriods(ITimePeriodContainer periods, bool combinePeriods = true) { if (periods == null) { throw new ArgumentNullException("periods"); } TimeLine <T> timeLine = new TimeLine <T>(periods, periodMapper); return(timeLine.IntersectPeriods(combinePeriods)); } // IntersectPeriods
// ---------------------------------------------------------------------- protected TimeLinePeriodEvaluator(ITimePeriodContainer periods, ITimePeriodMapper periodMapper = null) { if (periods == null) { throw new ArgumentNullException("periods"); } this.periods = periods; this.periodMapper = periodMapper; } // TimeLinePeriodEvaluator
} // PeriodMapper // ---------------------------------------------------------------------- public virtual ITimePeriodCollection GetGaps(ITimePeriodContainer periods, ITimePeriod limits = null) { if (periods == null) { throw new ArgumentNullException("periods"); } TimeLine <T> timeLine = new TimeLine <T>(periods, limits, periodMapper); return(timeLine.CalculateGaps()); } // GetGaps
} // TimeLine // ---------------------------------------------------------------------- public TimeLine(ITimePeriodContainer periods, ITimePeriod limits = null, ITimePeriodMapper periodMapper = null) { if (periods == null) { throw new ArgumentNullException("periods"); } this.limits = limits != null ? new TimeRange(limits) : new TimeRange(periods); this.periods = periods; this.periodMapper = periodMapper; } // TimeLine
/// <summary> /// <paramref name="limits"/> 기간내에서 <paramref name="excludedPeriods"/> 컬렉션의 기간들을 제외한 기간(Gap)을 계산해 낸다. /// </summary> /// <param name="excludedPeriods">제외할 기간들을 나타냅니다.</param> /// <param name="limits">전체 범위를 나타냅니다 (null이면 무한대의 범위를 나타냅니다)</param> /// <returns></returns> public virtual ITimePeriodCollection GetGaps(ITimePeriodContainer excludedPeriods, ITimePeriod limits = null) { excludedPeriods.ShouldNotBeNull("periods"); if (IsDebugEnabled) { log.Debug("Period들의 Gap들을 계산합니다... excludedPeriods=[{0}], limits=[{1}]", excludedPeriods, limits); } var timeLine = new TimeLine <T>(excludedPeriods, limits, PeriodMapper); return(timeLine.CalcuateGaps()); }
} // PeriodMapper // ---------------------------------------------------------------------- public virtual ITimePeriodCollection SubtractPeriods(ITimePeriodContainer sourcePeriods, ITimePeriodCollection subtractingPeriods, bool combinePeriods = true) { if (sourcePeriods == null) { throw new ArgumentNullException("sourcePeriods"); } if (subtractingPeriods == null) { throw new ArgumentNullException("subtractingPeriods"); } if (sourcePeriods.Count == 0) { return(new TimePeriodCollection()); } if (subtractingPeriods.Count == 0 && !combinePeriods) { return(new TimePeriodCollection(sourcePeriods)); } // combined source periods sourcePeriods = timePeriodCombiner.CombinePeriods(sourcePeriods); // combined subtracting periods if (subtractingPeriods.Count == 0) { return(new TimePeriodCollection(sourcePeriods)); } subtractingPeriods = timePeriodCombiner.CombinePeriods(subtractingPeriods); // invert subtracting periods sourcePeriods.AddAll(timeGapCalculator.GetGaps(subtractingPeriods, new TimeRange(sourcePeriods.Start, sourcePeriods.End))); return(timePeriodIntersector.IntersectPeriods(sourcePeriods, combinePeriods)); } // SubtractPeriods
public TimeLine(ITimePeriodContainer periods, ITimePeriodMapper periodMapper) : this(periods, null, periodMapper) { }
public TimeLine(ITimePeriodContainer periods) : this(periods, null, null) { }
/// <summary> /// <paramref name="periods"/>의 기간들을 결합하여, <see cref="ITimePeriodCollection"/>을 생성합니다. /// </summary> /// <param name="periods"></param> /// <returns></returns> public virtual ITimePeriodCollection CombinePeriods(ITimePeriodContainer periods) { periods.ShouldNotBeNull("periods"); return(new TimeLine <T>(periods, PeriodMapper).CombinePeriods()); }