Ejemplo n.º 1
0
        /// <summary>
        /// Reverse the direction of a train by reflecting its timing points around the final one.  In other words, a train which arrives at its destination at 4pm will become a train
        /// which departs from that location at 4pm in the opposite direction and has its section times and dwell times unchanged.
        /// </summary>
        public void Reverse()
        {
            TimeOfDay reflectAbout = LastTrainTime?.Time;

            if (reflectAbout == null)
            {
                return;
            }
            for (int i = 0; i < TrainTimes.Count; ++i)
            {
                TrainTimes[i].Reflect(reflectAbout, i == 0 || i == TrainTimes.Count - 1);
            }
            TrainTimes.Sort(new TrainLocationArrivalTimeComparer());
        }
 private void ReadTrainTimes(XmlReader reader)
 {
     reader.ReadStartElement();
     do
     {
         reader.MoveToContent();
         if (reader.NodeType == XmlNodeType.EndElement)
         {
             break;
         }
         TrainLocationTimeModel ttm = new TrainLocationTimeModel();
         ttm.ReadXml(reader);
         TrainTimes.Add(ttm);
     } while (true);
     reader.ReadEndElement();
 }