/// <summary> /// Shows all talks in a feed. /// </summary> /// <param name="feed"></param> private static void ShowTalks(Feed feed) { foreach (Talk talk in feed.Talks) { Console.WriteLine("[{0}] {1} ({2})", talk.StartTime, talk.Title, talk.Speaker); } }
/// <summary> /// Loads the feed with the specified ID. /// </summary> /// <param name="id">The unique ID of the feed to load.</param> /// <param name="limit">The maximum number of talks to load. Unlimited if null.</param> /// <param name="startTime">Talks which start before the value of this DateTime object will not be loaded.</param> /// <param name="endTime">Talks which start later than the value of this DateTime object will not be loaded.</param> /// <param name="reverseOrder">A value indicating whether results should be returned in reverse order.</param> /// <returns>Returns a snapshot of the feed with the specified ID.</returns> public static Feed Load( Int32 id, Int32? limit = null, DateTime? startTime = null, DateTime? endTime = null, Boolean reverseOrder = false) { Feed result = new Feed(id); // construct a URL for the requested feed QueryBuilder queryBuilder = new QueryBuilder(result.url); // talks.cam ignores the value of reverse_order, so we only add it if it is true if(reverseOrder) queryBuilder.Parameters.Add("reverse_order", reverseOrder); if (limit != null) queryBuilder.Parameters.Add("limit", limit); if (startTime.HasValue) queryBuilder.Parameters.Add("start_time", startTime.Value.ToUnix()); if (endTime.HasValue) queryBuilder.Parameters.Add("end_time", endTime.Value.ToUnix()); // load the xml XmlReader reader = XmlReader.Create(queryBuilder.ToString()); XDocument doc = XDocument.Load(reader); XElement root = doc.Root; result.name = root.Element("name").Value; result.details = root.Element("details").Value; result.url = root.Element("url").Value; foreach (XElement talk in root.Elements("talk")) { Talk t = Talk.Load(talk); result.talks.Add(t); } return result; }