public static Track FromSessionInfo(SessionInfo info) { var track = new Track(); var query = info["WeekendInfo"]; track.Id = Parser.ParseInt(query["TrackID"].GetValue()); track.Name = query["TrackDisplayName"].GetValue(); track.CodeName = query["TrackName"].GetValue(); track.Length = Parser.ParseTrackLength(query["TrackLength"].GetValue()); return track; }
public static Track FromSessionInfo(SessionInfo info) { var track = new Track(); var query = info["WeekendInfo"]; track.Id = Parser.ParseInt(query["TrackID"].GetValue()); track.Name = query["TrackDisplayName"].GetValue(); track.CodeName = query["TrackName"].GetValue(); track.Length = Parser.ParseTrackLength(query["TrackLength"].GetValue()); track.NightMode = query["WeekendOptions"]["NightMode"].GetValue() == "1"; // Parse sectors track.Sectors.Clear(); query = info["SplitTimeInfo"]["Sectors"]; int nr = 0; while (nr >= 0) { var pctString = query["SectorNum", nr]["SectorStartPct"].GetValue(); float pct; if (string.IsNullOrWhiteSpace(pctString) || !float.TryParse(pctString, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out pct)) { break; } var sector = new Sector(); sector.Number = nr; sector.StartPercentage = pct; track.Sectors.Add(sector); nr++; } return track; }
public void Update(SessionInfo info) { this.Track = Track.FromSessionInfo(info); this.SubsessionId = Parser.ParseInt(info["WeekendInfo"]["SubSessionID"].GetValue()); var session = info["SessionInfo"]["Sessions"]["SessionNum", Sim.Instance.CurrentSessionNumber]; this.EventType = session["SessionType"].GetValue(); var laps = session["SessionLaps"].GetValue(); var time = Parser.ParseSec(session["SessionTime"].GetValue()); this.RaceLaps = laps; this.RaceTime = time; }