public static Competitor FromXmlObject(CompetitorXml source)
        {
            Guard.NotNull(source, nameof(source));
            string name    = AssertHandlerNameNotEmpty(source);
            string dogName = AssertDogNameNotEmpty(source);

            return(new Competitor(source.Number, name, dogName).ChangeCountryCode(source.CountryCode));
        }
        private static string AssertDogNameNotEmpty(CompetitorXml source)
        {
            if (string.IsNullOrWhiteSpace(source.DogName))
            {
                throw new InvalidDataException("Competitor dog name is missing or empty in XML file.");
            }

            return(source.DogName);
        }
        public static CompetitionRunResultXml ToXmlObject(CompetitionRunResult source)
        {
            Guard.NotNull(source, nameof(source));

            return(new CompetitionRunResultXml
            {
                Competitor = CompetitorXml.ToXmlObject(source.Competitor),
                Timings = CompetitionRunTimingsXml.ToXmlObject(source.Timings),
                FaultCount = source.FaultCount,
                RefusalCount = source.RefusalCount,
                IsEliminated = source.IsEliminated
            });
        }
        public static CompetitionRunResult FromXmlObject(CompetitionRunResultXml source)
        {
            Guard.NotNull(source, nameof(source));
            CompetitorXml competitor = AssertCompetitorNotNull(source);

            // @formatter:keep_existing_linebreaks true

            return(new CompetitionRunResult(CompetitorXml.FromXmlObject(competitor))
                   .ChangeTimings(CompetitionRunTimingsXml.FromXmlObject(source.Timings))
                   .ChangeFaultCount(source.FaultCount)
                   .ChangeRefusalCount(source.RefusalCount)
                   .ChangeIsEliminated(source.IsEliminated));

            // @formatter:keep_existing_linebreaks restore
        }