Beispiel #1
0
            public string Serialize() {
                var s = new StringWriter();
                var w = new JsonTextWriter(s);
                w.WriteStartObject();

                w.Write(nameof(CarId), CarId);
                w.Write(nameof(TrackId), TrackId);

                w.Write(nameof(StartedAt), StartedAt);
                w.Write(nameof(Time), Time);
                w.Write(nameof(BestLap), BestLap);
                w.Write(nameof(BestLapId), BestLapId);

                w.WriteNonDefault(nameof(GoneOffroad), GoneOffroad);
                w.WriteNonDefault(nameof(Penalties), Penalties);

                w.WriteNonDefault(nameof(MaxSpeed), MaxSpeed, "F1");
                w.WriteNonDefault(nameof(Distance), Distance, "F1");
                w.WriteNonDefault(nameof(FuelBurnt), FuelBurnt, "F1");
                w.WriteNonDefault(nameof(LongestAirborne), LongestAirborne, "F3");
                w.WriteNonDefault(nameof(LongestWheelie), LongestWheelie, "F3");
                w.WriteNonDefault(nameof(LongestTwoWheels), LongestTwoWheels, "F3");
                w.WriteNonDefault(nameof(TotalAirborne), TotalAirborne, "F2");
                w.WriteNonDefault(nameof(TotalWheelie), TotalWheelie, "F2");
                w.WriteNonDefault(nameof(TotalTwoWheels), TotalTwoWheels, "F2");
                w.WriteNonDefault(nameof(TotalTyreWear), TotalTyreWear, "F3");

                w.WriteEndObject();
                return s.ToString();
            }