private static string ConvertRealtimeInfoToString(RealtimeInfo info) { string output = ""; foreach (var bus in info.Buses) { if (bus.LineNumber.Count() == 2) { output += String.Format("{0} {2} {1}X", bus.LineNumber, bus.DepartTime, bus.Destination); } else { output += String.Format("{0} {2} {1}X", bus.LineNumber, bus.DepartTime, bus.Destination); } } return output; }
public static RealtimeInfo ConvertHtmlNodeToBuses(IEnumerable<HtmlNode> buses) { if(buses==null) throw new ArgumentNullException("buses"); var tempList = new List<HtmlNode>(buses); var myBuses = new List<Bus>(); var info = new RealtimeInfo(); for(int i=0;i<tempList.Count;i += 3) { var tmpBus = new Bus { LineNumber = HtmlNodeToString(tempList[i]), Destination = HtmlNodeToString(tempList[i + 1]), DepartTime = HtmlNodeToString(tempList[i + 2]) }; info.Buses.Add(tmpBus); } return info; }
public void Publish(RealtimeInfo info) { _publishSocket.Send(ConvertRealtimeInfoToString(info), Encoding.Unicode); Console.WriteLine("sending bus information"); }