public List <TrafficEvent> FetchTravelTimes() { TrafficEvent travelTime = new TrafficEvent(); travelTime.Title = "No Travel Times are reported."; travelTime.Description = ""; travelTimesList.Add(travelTime); return(travelTimesList); }
public List <TrafficEvent> FetchLaneClosures() { TrafficEvent laneClosure = new TrafficEvent(); laneClosure.Title = "IH-10 EAST Eastbound Exit Ramp to FEDERAL RD"; laneClosure.Description = "Closed continuously until 3:00 PM, Wednesday, May 18 - Lanes Affected: TOTAL CLOSURE - Status: Active"; laneClosuresList.Add(laneClosure); return(laneClosuresList); }
/// <summary> Handles the result received from LoadItems() /// </summary> /// <param name="result"></param> void ResponseCallback(IAsyncResult result) { var request = (HttpWebRequest)result.AsyncState; var response = request.EndGetResponse(result); var stream = response.GetResponseStream(); var reader = XmlReader.Create(stream); var items = new List <TrafficEvent>(50); TrafficEvent item = null; while (reader.Read()) { var nodeName = reader.Name; var nodeType = reader.NodeType; if (nodeName == "item") { if (nodeType == XmlNodeType.Element) { item = new TrafficEvent(); } else if (nodeType == XmlNodeType.EndElement) { if (item != null) { items.Add(item); item = null; } } continue; } if (nodeType != XmlNodeType.Element) { continue; } if (item == null) { continue; } reader.MoveToContent(); var nodeValue = reader.ReadElementContentAsString(); if (nodeName == "title") { item.Title = nodeValue; } else if (nodeName == "description") { item.Description = Regex.Replace(nodeValue, @"<(.|\n)*?>", string.Empty); } } if (ItemsReceived != null) { ItemsReceived(this, items); } if (items != null) { App.incidentsList = items; } }