AK.F1.Timing.Service.Utility.IcsConverter.ToXDocument C# (CSharp) Метод

ToXDocument() публичный статический Метод

Converts the specified http://www.f1calendar.com/ ICS file to a race XML document schema expected by the service.
/// Thrown when is . /// /// Thrown when is of zero length. ///
public static ToXDocument ( string path, int startTimeOffset = -2 ) : System.Xml.Linq.XDocument
path string The path of the ICS file.
startTimeOffset int The start time offset (in minutes).
Результат System.Xml.Linq.XDocument
        public static XDocument ToXDocument(string path, int startTimeOffset = -2)
        {
            Guard.NotNullOrEmpty(path, "path");

            int i = 0;
            var calendar = iCalendar.LoadFromFile(path);
            return new XDocument(
                new XElement("races",
                    from e in calendar.First().Events
                    group e by GetRaceId(e) into race
                    orderby race.Min(session => session.Start)
                    select new XElement("race",
                        new XAttribute("id", String.Format(CultureInfo.InvariantCulture, "{0:00}-{1}", ++i, race.Key)),
                        new XAttribute("name", GetRaceName(race.First())),
                        new XAttribute("location", race.First().Location),
                        from session in race
                        orderby session.Start
                        select new XElement("session",
                            new XAttribute("id", GetSessionId(session)),
                            new XAttribute("name", GetSessionName(session)),
                            new XAttribute("startTimeUtc", session.Start.AddMinutes(startTimeOffset).ToString("o", CultureInfo.InvariantCulture))))));
        }