private static void CheckPrediction(IRun run, TimeSpan?[] predictions, TimeSpan?predictedTime, int startingIndex, int endingIndex, int runIndex, TimingMethod method = TimingMethod.RealTime, CleanUpCallback callback = null) { if (predictedTime.HasValue && (!predictions[endingIndex + 1].HasValue || predictedTime < predictions[endingIndex + 1].Value)) { var segmentHistoryElement = run[endingIndex].SegmentHistory.FirstOrDefault(x => x.Index == runIndex); var parameters = new CleanUpCallbackParameters { startingSegment = run[startingIndex], endingSegment = run[endingIndex], timeBetween = segmentHistoryElement.Time[method].Value, combinedSumOfBest = predictions[endingIndex + 1].Value - predictions[startingIndex + 1].Value, runElement = run.RunHistory.FirstOrDefault(x => x.Index == runIndex), method = method }; if (callback == null || callback(parameters)) { run[endingIndex].SegmentHistory.Remove(segmentHistoryElement); } } }
private static void CheckPrediction(IRun run, TimeSpan?[] predictions, TimeSpan?predictedTime, int startingIndex, int endingIndex, int runIndex, TimingMethod method, CleanUpCallback callback) { if (predictedTime.HasValue && (!predictions[endingIndex + 1].HasValue || predictedTime < predictions[endingIndex + 1].Value)) { Time segmentHistoryElement; if (run[endingIndex].SegmentHistory.TryGetValue(runIndex, out segmentHistoryElement)) { var parameters = new CleanUpCallbackParameters { startingSegment = startingIndex >= 0 ? run[startingIndex] : null, endingSegment = endingIndex >= 0 ? run[endingIndex] : null, timeBetween = segmentHistoryElement[method].Value, combinedSumOfBest = predictions[endingIndex + 1].HasValue ? (TimeSpan?)(predictions[endingIndex + 1].Value - predictions[startingIndex + 1].Value) : null, attempt = run.AttemptHistory.FirstOrDefault(x => x.Index == runIndex), method = method }; if (callback == null || callback(parameters)) { run[endingIndex].SegmentHistory.Remove(runIndex); } } } }
private static void CheckPrediction(IRun run, TimeSpan?[] predictions, TimeSpan? predictedTime, int startingIndex, int endingIndex, int runIndex, TimingMethod method, CleanUpCallback callback) { if (predictedTime.HasValue && (!predictions[endingIndex + 1].HasValue || predictedTime < predictions[endingIndex + 1].Value)) { Time segmentHistoryElement; if (run[endingIndex].SegmentHistory.TryGetValue(runIndex, out segmentHistoryElement)) { var parameters = new CleanUpCallbackParameters { startingSegment = startingIndex >= 0 ? run[startingIndex] : null, endingSegment = endingIndex >= 0 ? run[endingIndex] : null, timeBetween = segmentHistoryElement[method].Value, combinedSumOfBest = predictions[endingIndex + 1].HasValue ? (TimeSpan?)(predictions[endingIndex + 1].Value - predictions[startingIndex + 1].Value) : null, attempt = run.AttemptHistory.FirstOrDefault(x => x.Index == runIndex), method = method }; if (callback == null || callback(parameters)) { run[endingIndex].SegmentHistory.Remove(runIndex); } } } }