예제 #1
0
        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;
        }
예제 #2
0
파일: WebParser.cs 프로젝트: karaaie/SLInfo
        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;
        }
예제 #3
0
 public void Publish(RealtimeInfo info)
 {
     _publishSocket.Send(ConvertRealtimeInfoToString(info), Encoding.Unicode);
     Console.WriteLine("sending bus information");
 }