コード例 #1
0
        /// <summary>
        /// Decodes the line from the website into a RaceResultModel.
        /// </summary>
        public static RaceResult ParseToRaceResultWithPartialRaceTimes(string line, int year)
        {
            var model = new RaceResult();

            model.year = year.ToString();

            model.categorie = line.Substring(0, 10).Trim();
            model.rang      = line.Substring(11, 5).Trim().Replace(".", "");
            var nom = line.Substring(16, 35).Trim();
            var an  = line.Substring(52, 4).Trim();

            model.equipe_ou_lieu = line.Substring(57, 27).Trim();
            model.temps          = line.Substring(85, 8).Trim();

            model.temps_partiel_1 = "----";
            model.temps_partiel_2 = "----";

            var parts = line.Split('¦');

            if (parts.Length == 4)
            {
                model.temps_partiel_1 = parts[1].TrimStart().Split(' ')[0].Trim();
                model.temps_partiel_2 = parts[2].TrimStart().Split(' ')[0].Trim();
            }

            //if (model.temps_partiel_1 == "0:----" || model.temps_partiel_2 == "0:----")
            //    model.temps_partiel_2 = model.temps_partiel_2;

            // Remove last comma from "race time":
            model.temps = model.temps.Substring(0, model.temps.Length - 1);

            model.participant = new Participant(nom, an, model.GetGender());

            if (an != "????")
            {
                model.age = (int.Parse(model.year) - int.Parse(an)).ToString();
            }

            return(model);
        }
コード例 #2
0
        private static RaceResult ParseToRaceResult(string line)
        {
            var cells      = line.Split(Separator);
            var raceResult = new RaceResult
            {
                year            = cells[0],
                categorie       = cells[1],
                rang            = cells[2],
                age             = cells[5],
                equipe_ou_lieu  = cells[6],
                temps           = cells[7],
                temps_partiel_1 = cells[8],
                temps_partiel_2 = cells[9]
            };

            var nom = cells[3];
            var an  = cells[4];

            raceResult.participant = new Participant(nom, an, raceResult.GetGender());

            return(raceResult);
        }