コード例 #1
0
 private static StationExit CreateStationExit(TrackLayout layout, string stationNameOrSignature)
 {
     var stationExit = new StationExit(stationNameOrSignature);
     var station = layout.Station(stationNameOrSignature);
     station.Add(stationExit);
     return stationExit;
 }
コード例 #2
0
 internal TrackStretch(StationExit start, StationExit end, double distance, int tracksCount) {
     Start = start;
     End = end;
     Start.Stretch = this;
     End.Stretch = this;
     Distance = distance;
     TracksCount = tracksCount;
 }
コード例 #3
0
 public TrackStretch Add(StationExit from, StationExit to, double distance, int tracksCount) {
     if (null == from) throw new ArgumentNullException(nameof(from));
     if (null == to) throw new ArgumentNullException(nameof(to));
     if (!HasExit(from)) throw new TrackLayoutException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.StationExitIsNotInLayout, from));
     if (!HasExit(to)) throw new TrackLayoutException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.StationExitIsNotInLayout, to));
     _trackStretches.Add(new TrackStretch(from, to, distance, tracksCount));
     return _trackStretches.Last();
 }
コード例 #4
0
ファイル: Station.cs プロジェクト: fjallemark/TrainDispatch
 public void Add(StationExit exit) {
     if (exit == null) throw new ArgumentNullException(nameof(exit));
     exit.Station = this;
     _exits.Add(exit);
 }
コード例 #5
0
 internal TrackStretch(StationExit start, StationExit end, double distance) : this(start, end, distance, 1) { }
コード例 #6
0
 public TrackStretch Add(StationExit from, StationExit to, double distance) {
     return Add(from, to, distance, 1);
 }
コード例 #7
0
 public bool HasExit(StationExit exit) { return StationExits.Any(e => e.Equals(exit)); }
コード例 #8
0
        private static void GetStretches(TrackLayout layout, Excel.Workbook book) {
            Excel.Worksheet sheet = book.Worksheets["Routes"];
            var r = 2;
            while (true) {
                var row = (Array)sheet.get_Range(Cell("A", r), Cell("I", r)).Cells.Value;
                if (row.GetValue(1, 1) == null) {
                    break;
                }
                else {
                    var timetableStretchNumber = row.Value(1);
                    var tracksCount = int.Parse(row.Value(8), CultureInfo.InvariantCulture);
                    var fromName = row.Value(3);
                    var toName = row.Value(5);
                    var distance = double.Parse(row.Value(9), CultureInfo.InvariantCulture);

                    var fromStation = layout.Station(fromName);
                    var fromExit = new StationExit(toName);
                    fromStation.Add(fromExit);
                    var toStation = layout.Station(toName);
                    var toExit = new StationExit(fromName);
                    toStation.Add(toExit);
                    var addedStretch = layout.Add(fromExit, toExit, distance, tracksCount);
                    if (! layout.HasTimetableStretch(timetableStretchNumber)) {
                        layout.Add(new TimetableStretch(timetableStretchNumber));
                    }
                    layout.TimetableStretch(timetableStretchNumber).Add(addedStretch);
                }
                r++;
            }
        }