protected CompetitionRunResult(Competitor competitor, CompetitionRunTimings?timings, int faultCount, int refusalCount, bool isEliminated,
                                int placement)
     : this(competitor)
 {
     Timings      = timings;
     FaultCount   = faultCount;
     RefusalCount = refusalCount;
     IsEliminated = isEliminated;
     Placement    = placement;
 }
        public CompetitionRunResult ChangeCompetitor(Competitor competitor)
        {
            Guard.NotNull(competitor, nameof(competitor));

            return(new CompetitionRunResult(competitor, Timings, FaultCount, RefusalCount, IsEliminated, Placement));
        }
        public CompetitionRunResult(Competitor competitor)
        {
            Guard.NotNull(competitor, nameof(competitor));

            Competitor = competitor;
        }
Ejemplo n.º 4
0
        private static CompetitionRunResult GetRunResultFrom(IDelimitedValuesReaderRow row, bool hasOptionalColumns, DateTime startTimeUtc)
        {
            Competitor competitor = GetCompetitorFrom(row);
            var        runResult  = new CompetitionRunResult(competitor);

            if (hasOptionalColumns)
            {
                int? faultCount   = row.GetCell <int?>(ImportExportColumns.FaultCount);
                int? refusalCount = row.GetCell <int?>(ImportExportColumns.RefusalCount);
                bool?isEliminated = row.GetCell <bool?>(ImportExportColumns.IsEliminated);

                // Note: We cannot reconstruct whether start time was high precision, because it does not roundtrip
                // through import/export. However, we do not need to know. A low-precision elapsed time is caused by
                // either one or both times to be low precision. So although we lost some information, the nett effect
                // when the precision of an elapsed time is recalculated will be the same as long as we assume that the start
                // time was high precision.
                var startTime = new RecordedTime(TimeSpan.Zero, startTimeUtc);

                RecordedTime?intermediateTime1 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime1, startTime);
                RecordedTime?intermediateTime2 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime2, startTime);
                RecordedTime?intermediateTime3 = GetTimeElapsedSinceStart(row, ImportExportColumns.IntermediateTime3, startTime);
                RecordedTime?finishTime        = GetTimeElapsedSinceStart(row, ImportExportColumns.FinishTime, startTime);

                if (intermediateTime1 == null && intermediateTime2 == null && intermediateTime3 == null && finishTime == null)
                {
                    startTime = null;
                }

                bool runCompleted = finishTime != null || (isEliminated != null && isEliminated.Value);

                if (runCompleted)
                {
                    if (faultCount != null)
                    {
                        runResult = runResult.ChangeFaultCount(faultCount.Value);
                    }

                    if (refusalCount != null)
                    {
                        runResult = runResult.ChangeRefusalCount(refusalCount.Value);
                    }

                    if (isEliminated != null)
                    {
                        runResult = runResult.ChangeIsEliminated(isEliminated.Value);
                    }

                    if (startTime != null)
                    {
                        // @formatter:keep_existing_linebreaks true

                        runResult = runResult
                                    .ChangeTimings(new CompetitionRunTimings(startTime)
                                                   .ChangeIntermediateTime1(intermediateTime1)
                                                   .ChangeIntermediateTime2(intermediateTime2)
                                                   .ChangeIntermediateTime3(intermediateTime3)
                                                   .ChangeFinishTime(finishTime));

                        // @formatter:keep_existing_linebreaks restore
                    }
                }
            }

            return(runResult);
        }