public TrackStretch Add(TrackStretch stretch)
 {
     if (stretch == null)
     {
         throw new ArgumentNullException(nameof(stretch));
     }
     if (TrackStretches.Contains(stretch))
     {
         return(stretch);
     }
     TrackStretches.Add(stretch);
     return(TrackStretches.Last());
 }
 public void Add(TrackStretch stretch)
 {
     if (stretch == null)
     {
         throw new ArgumentNullException(nameof(stretch));
     }
     if (Stretches.Count > 0 && stretch.End.Station.Equals(Stretches.Last().Start.Station))
     {
         Stretches.Insert(0, stretch);
     }
     else
     {
         Stretches.Add(stretch);
     }
 }
        internal static IEnumerable <Message> GetValidationErrors(this TrackStretch me)
        {
            var result   = new List <Message>();
            var passings = me.Passings.OrderBy(p => p.Departure).ToArray();

            for (var i = 0; i < passings.Length - me.TracksCount; i++)
            {
                var first  = passings[i];
                var second = passings[i + me.TracksCount];
                if (second.To.Arrival > first.From.Departure)
                {
                    result.Add(Message.Warning(CultureInfo.CurrentCulture, $"Train {first.Train} between {first} is in conflict with {second.Train} between {second}."));
                }
            }
            return(result);
        }
 public StationExit(string name, TrackStretch stretch) : this(name)
 {
     Stretch = stretch ?? throw new ArgumentNullException(nameof(stretch));
 }