private static void PopulatePredictions(IRun run, TimeSpan?currentTime, int segmentIndex, IList <TimeSpan?> predictions, bool simpleCalculation, bool useCurrentRun, TimingMethod method) { if (currentTime != null) { PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1); if (!simpleCalculation) { foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Value[method].HasValue)) { Time segmentTime; if (segmentIndex == 0 || !run[segmentIndex - 1].SegmentHistory.TryGetValue(nullSegment.Key, out segmentTime) || segmentTime[method] != null) { var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Key, method); PopulatePrediction(predictions, prediction.Time[method], prediction.Index); } } } if (useCurrentRun) { var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method); PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index); } var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method); PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index); } }
private static void PopulatePredictions(IRun run, TimeSpan?currentTime, int segmentIndex, IList <TimeSpan?> predictions, bool simpleCalculation, TimingMethod method = TimingMethod.RealTime) { if (currentTime != null) { PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1); if (!simpleCalculation) { foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Time[method].HasValue)) { var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Index, method); PopulatePrediction(predictions, prediction.Time[method], prediction.Index); } } var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method); PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index); var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method); PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index); } }
private static void PopulatePredictions(IRun run, TimeSpan?currentTime, int segmentIndex, IList <TimeSpan?> predictions, bool useCurrentRun, TimingMethod method) { if (currentTime != null) { PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1); foreach (var segment in run[segmentIndex].SegmentHistory) { var segmentTime = segmentIndex > 0 ? run[segmentIndex - 1].SegmentHistory.FirstOrDefault(x => x.Index == segment.Index) : null; if (segmentTime == null || segmentTime.Time[method] != null) { var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex, segment.Index, method); PopulatePrediction(predictions, prediction.Time[method], prediction.Index); } } if (useCurrentRun) { var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method); PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index); } var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method); PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index); } }