Exemple #1
0
        private void InitializeGridView(GridView view, TrainDirection dir)
        {
            var stations = tt.GetLinearStationsOrderedByDirection(dir);

            view.AddColumn <DataElement>(t => t.Train.TName, T._("Zugnummer"));
#pragma warning disable CA2000
            foreach (var sta in stations)
            {
                if (sta != stations.First())
                {
                    view.AddColumn(GetCell(t => t.Arrival, sta, true, view), T._("{0} an", sta.SName));
                }
                if (sta != stations.Last())
                {
                    view.AddColumn(GetCell(t => t.Departure, sta, false, view), T._("{0} ab", sta.SName));
                }
            }
#pragma warning restore CA2000
            view.AddColumn <DataElement>(t => GetTransition(t.Train), T._("Folgezug"));

            var l = tt.Trains.Where(t => t.Direction == dir).Select(tra => new DataElement()
            {
                Train   = tra,
                ArrDeps = tra.GetArrDepsUnsorted()
            }).ToList();

            view.GotFocus += (s, e) => focused = view;
            view.KeyDown  += (s, e) => HandleViewKeystroke(e, view);
            if (mpmode)
            {
                l.Add(null);
            }

            view.DataStore = l.ToArray();
        }
Exemple #2
0
        public Station[] GetLastStations(TrainDirection dir, Station sta, IEnumerable <Train> trainsInThisDir)
        {
            if (TT.Type == TimetableType.Linear)
            {
                var lSta = TT.GetStationsOrderedByDirection(dir).LastOrDefault();
                if (lSta != sta)
                {
                    return new[] { lSta }
                }
                ;
                return(Array.Empty <Station>());
            }

            // Alle Stationen in Zügen dieser Richtung, die nach dieser Station folgen
            var stasInTrains = trainsInThisDir.SelectMany(t => t.GetArrDeps().Where(a => a.Value.HasMinOneTimeSet).Select(kvp => kvp.Key).SkipWhile(s => s != sta)).ToArray();

            var connectionNodes        = sta._parent.Stations.Where(s => s.Routes.Length > 1);
            var visitedConnectionNodes = connectionNodes.Intersect(stasInTrains); // Eine Hälfte der "Richtungsangaben": Verbindungsknoten im Netz

            var visitedRoutes = stasInTrains.SelectMany(s => s.Routes).Distinct();

            var stasAfter = new List <Station>();

            stasAfter.AddRange(visitedConnectionNodes);

            foreach (var rt in visitedRoutes)
            {
                var route = sta._parent.GetRoute(rt).GetOrderedStations();
                stasAfter.Add(route.First());
                stasAfter.Add(route.Last());
            }

            return(stasAfter.Distinct().OrderBy(s => s.SName).ToArray());
        }
Exemple #3
0
        private Train[] GetTrains(TrainDirection dir)
        {
            if (trainCache == null)
            {
                var stasAfter = GetStationsInDir(dir);
                trainCache = tt.Trains.Where(t =>
                {
                    var p      = t.GetPath();
                    var ardeps = t.GetArrDeps();

                    var intersect = stasAfter.Intersect(p)
                                    .Where(s => ardeps[s].HasMinOneTimeSet);

                    if (intersect.Count() == 0)
                    {
                        return(false);
                    }

                    var time1 = ardeps[intersect.First()].FirstSetTime;
                    var time2 = ardeps[intersect.Last()].FirstSetTime;

                    return(time1 < time2);
                }).ToArray();
            }
            return(trainCache);
        }
Exemple #4
0
 protected void DeleteTrain(GridView view, TrainDirection dir, bool message = true)
 {
     if (view.SelectedItem != null)
     {
         if (view.SelectedItem is Train train)
         {
             if (train.TrainLinks.Any(l => l.TrainCount > 0))
             {
                 if (message)
                 {
                     MessageBox.Show(T._("Der Zug kann nicht gelöscht werden, da er mindestens von einem verlinkten Zug referenziert wird!"), T._("Zug löschen"));
                 }
             }
             else
             {
                 tt.RemoveTrain(train);
                 UpdateListView(view, dir);
             }
         }
         else if (message)
         {
             MessageBox.Show(T._("Verlinke Züge können nicht gelöscht werden."), T._("Zug löschen"));
         }
     }
     else if (message)
     {
         MessageBox.Show(T._("Zuerst muss ein Zug ausgewählt werden!"), T._("Zug löschen"));
     }
 }
Exemple #5
0
        public string?GetTrack(ITrain train, Station sta, TrainDirection dir, ArrDep timetableEntry, TrackQuery track)
        {
            var path = new TrainPathData(train.ParentTimetable, train);

            if (!path.ContainsStation(sta))
            {
                return(null);
            }

            var exitRoute = path.GetExitRoute(sta);

            if (track == TrackQuery.Departure)
            {
                return(Fallback(timetableEntry.DepartureTrack,
                                Fallback(timetableEntry.ArrivalTrack,
                                         Fallback(dir == TrainDirection.ti
                            ? sta.DefaultTrackRight.GetValue(exitRoute)
                            : sta.DefaultTrackLeft.GetValue(exitRoute), ""))));
            }

            return(Fallback(timetableEntry.ArrivalTrack,
                            Fallback(timetableEntry.DepartureTrack,
                                     Fallback(dir == TrainDirection.ti
                        ? sta.DefaultTrackRight.GetValue(exitRoute)
                        : sta.DefaultTrackLeft.GetValue(exitRoute), ""))));
        }
        private void InitializeGridView(GridView view, TrainDirection dir)
        {
            var stations = tt.GetStationsOrderedByDirection(dir);

            view.AddColumn <DataElement>(t => t.Train.TName, "Zugnummer");
            foreach (var sta in stations)
            {
                if (sta != stations.First())
                {
                    view.AddColumn(GetCell(t => t.Arrival, sta, true, view), sta.SName + " an");
                }
                if (sta != stations.Last())
                {
                    view.AddColumn(GetCell(t => t.Departure, sta, false, view), sta.SName + " ab");
                }
            }
            view.AddColumn <DataElement>(t => GetTransition(t.Train), "Folgezug");

            var l = tt.Trains.Where(t => t.Direction == dir).Select(tra => new DataElement()
            {
                Train   = tra,
                ArrDeps = tra.GetArrDeps()
            }).ToList();

            view.GotFocus += (s, e) => focused = view;
            view.KeyDown  += (s, e) => HandleViewKeystroke(e, view);
            if (mpmode)
            {
                l.Add(null);
            }

            view.DataStore = l;
        }
Exemple #7
0
        /// <summary>
        /// Returns all stations on all routes that are before or ahead of the current station.
        /// </summary>
        /// <exception cref="ArgumentException">The spcified train direction is <see cref="TrainDirection.tr"/>.</exception>
        public Station[] GetStationsInDir(TrainDirection direction, Station sta)
        {
            if (direction == TrainDirection.tr)
            {
                throw new ArgumentException("Invalid (non-linear) train direction specified", nameof(direction));
            }

            if (tt.Type == TimetableType.Linear)
            {
                var stas = tt.GetLinearStationsOrderedByDirection(direction);
                return(stas.Skip(stas.IndexOf(sta) + 1).ToArray());
            }
            var stasAfter = new List <Station>();

            foreach (var rt in sta.Routes)
            {
                var route        = tt.GetRoute(rt);
                var pos          = sta.Positions.GetPosition(rt);
                var nextStations = direction == TrainDirection.ti ?
                                   route.Stations.Where(s => s.Positions.GetPosition(rt) > pos) : // ti
                                   route.Stations.Where(s => s.Positions.GetPosition(rt) < pos);  // ta
                stasAfter.AddRange(nextStations);
            }
            return(stasAfter.ToArray());
        }
Exemple #8
0
        public Train[] GetTrains(TrainDirection dir, Station sta)
        {
            var stasAfter  = GetStationsInDir(dir, sta);
            var stasBefore = GetStationsInDir(dir == TrainDirection.ta ? TrainDirection.ti : TrainDirection.ta, sta);

            return(GetTrains(sta).Where(t =>
            {
                var p = t.GetPath();
                var ardeps = t.GetArrDepsUnsorted();

                var nsta = p.Where(s => stasAfter.Contains(s)).FirstOrDefault(s => ardeps[s].HasMinOneTimeSet);
                if (nsta == null)
                {
                    var lsta = p.Where(s => stasBefore.Contains(s)).FirstOrDefault(s => ardeps[s].HasMinOneTimeSet);
                    if (lsta == null)
                    {
                        return false;
                    }
                    var ltime = ardeps[lsta].FirstSetTime;
                    return ltime < ardeps[sta].Departure;
                }
                var ntime = ardeps[nsta].FirstSetTime;
                return ntime > ardeps[sta].Departure;
            }).ToArray());
        }
Exemple #9
0
 protected void SortTrains(GridView view, TrainDirection dir)
 {
     using (var tsd = new TrainSortDialog(dir, tt))
         if (tsd.ShowModal(this) == DialogResult.Ok)
         {
             UpdateListView(view, dir);
         }
 }
        public ActionResult DeleteDirection(int DirectionId, TrainDirection DeletedDirection)
        {
            var direction = db.TrainDirections.SingleOrDefault(d => d.ID == DirectionId);

            db.TrainDirections.Remove(direction);
            db.SaveChanges();
            return(RedirectToAction("ShowDirections"));
        }
        public ActionResult EditDirection(int DirectionId, TrainDirection updatedDirection)
        {
            var direction = db.TrainDirections.SingleOrDefault(d => d.ID == DirectionId);

            direction.Name = updatedDirection.Name;
            db.SaveChanges();
            return(RedirectToAction("ShowDirections"));
        }
Exemple #12
0
        public void SortTrainsAtStation(Timetable tt, TrainDirection dir, Station sta)
        {
            Train[] trains() => tt.Trains.Where(t => t.Direction == dir)
            .Where(t => t.GetPath().Contains(sta)).ToArray();

            TimeSpan TimeSelector(Train train) => train.GetArrDep(sta).FirstSetTime;
            bool TimeComparer(TimeSpan cur, TimeSpan next) => (cur != default) && (next != default) && (cur > next);

            InternalSort(tt, trains, TimeSelector, TimeComparer);
        }
Exemple #13
0
        /// <summary>
        /// Get all trains that pass through the given station with the provided direction.
        /// </summary>
        /// <param name="trains">Pre-filtered collection for trains. Only those trains will be taken into account.</param>
        /// <param name="dir">Linear "perceived" direction.</param>
        /// <param name="sta"></param>
        /// <exception cref="ArgumentException">The spcified train direction is <see cref="TrainDirection.tr"/>.</exception>
        public IEnumerable <ITrain> GetTrains(IEnumerable <ITrain> trains, TrainDirection dir, Station sta)
        {
            if (dir == TrainDirection.tr)
            {
                throw new ArgumentException("Invalid (non-linear) train direction specified", nameof(dir));
            }

            var stasAfter  = GetStationsInDir(dir, sta);
            var stasBefore = GetStationsInDir(dir == TrainDirection.ta ? TrainDirection.ti : TrainDirection.ta, sta);

            return(trains.Where(t =>
            {
                var path = t.GetPath();

                if (!path.Contains(sta))
                {
                    return false;
                }

                var ardeps = t.GetArrDepsUnsorted();
                var isStopping = ardeps[sta].HasMinOneTimeSet;

                Station?nextStopStation = path.Where(s => stasAfter.Contains(s)).FirstOrDefault(s => ardeps[s].HasMinOneTimeSet);
                Station?lastStopStation = null;
                if (nextStopStation == null || !isStopping)
                {
                    lastStopStation = path.Where(s => stasBefore.Contains(s)).FirstOrDefault(s => ardeps[s].HasMinOneTimeSet);
                }

                // We have a stop at this station, use time difference between first/last and current.
                if (isStopping)
                {
                    if (nextStopStation == null)
                    {
                        if (lastStopStation == null)
                        {
                            return false;
                        }
                        var lastStopTime = ardeps[lastStopStation].LastSetTime;
                        return lastStopTime < ardeps[sta].FirstSetTime;
                    }

                    var nextStopTime = ardeps[nextStopStation].FirstSetTime;
                    return nextStopTime > ardeps[sta].LastSetTime;
                }

                if (lastStopStation == null || nextStopStation == null)
                {
                    return false; // We are (proven!) not running over this station.
                }
                // Passthrough, use difference between first and last
                return ardeps[nextStopStation].FirstSetTime > ardeps[lastStopStation].LastSetTime;
            }));
        }
Exemple #14
0
        public Station[] GetStations(Route route, TrainDirection dir)
        {
            var stas = route.GetOrderedStations().Where(s => srules.All(r => !r.Matches(s)))
                       .ToArray();

            if (dir == TrainDirection.ta)
            {
                return(stas.Reverse().ToArray());
            }
            return(stas);
        }
Exemple #15
0
        protected void NewTrain(GridView view, TrainDirection direction)
        {
            using (var tef = new TrainEditForm(tt, direction))
            {
                if (tef.ShowModal(this) == DialogResult.Ok)
                {
                    tt.AddTrain(tef.Train, true);

                    UpdateListView(view, direction);
                }
            }
        }
 public ActionResult AddDirection(TrainDirection direction)
 {
     if (ModelState.IsValid == true)
     {
         TrainDirection NewDirection = new TrainDirection();
         NewDirection.Name = direction.Name;
         db.TrainDirections.Add(NewDirection);
         db.SaveChanges();
         return(RedirectToAction("ShowDirections"));
     }
     return(View(direction));
 }
Exemple #17
0
        public Station[] GetLastStations(TrainDirection dir, Station sta, IEnumerable <object> trainsInThisDirObj)
        {
            var trainsInThisDir = trainsInThisDirObj.Cast <Train>().ToArray(); // From JS.

            if (tt.Type == TimetableType.Linear)
            {
                var lSta = tt.GetLinearStationsOrderedByDirection(dir).LastOrDefault();
                if (lSta != sta)
                {
                    return new[] { lSta }
                }
                ;
                return(Array.Empty <Station>());
            }

            // Alle Stationen in Zügen dieser Richtung, die nach dieser Station folgen
            var stasInTrains = trainsInThisDir
                               .SelectMany(t => t.GetArrDepsUnsorted()
                                           .Where(a => a.Value.HasMinOneTimeSet)
                                           .Select(kvp => kvp.Key)
                                           .SkipWhile(s => s != sta))
                               .ToArray();

            var connectionNodes        = sta.ParentTimetable !.Stations.Where(s => s.Routes.Length > 1);
            var visitedConnectionNodes = connectionNodes.Intersect(stasInTrains); // Eine Hälfte der "Richtungsangaben": Verbindungsknoten im Netz

            var visitedRoutes = stasInTrains.SelectMany(s => s.Routes).Distinct();

            var stasAfter = new List <Station>();

            stasAfter.AddRange(visitedConnectionNodes);

            foreach (var rt in visitedRoutes)
            {
                var route = sta.ParentTimetable.GetRoute(rt).ToPathData(tt);
                if (stasInTrains.Contains(route.NextStation(sta)))
                {
                    stasAfter.Add(route.PathEntries.Last().Station);
                }
                if (stasInTrains.Contains(route.PreviousStation(sta)))
                {
                    stasAfter.Add(route.PathEntries.First().Station);
                }
            }

            return(stasAfter
                   .Except(new[] { sta })
                   .Distinct()
                   .Where(s => srules.All(r => !r.Matches(s)))
                   .OrderBy(s => s.SName)
                   .ToArray());
        }
Exemple #18
0
        protected void DeleteTrain(GridView view, TrainDirection dir, bool message = true)
        {
            if (view.SelectedItem != null)
            {
                tt.RemoveTrain((Train)view.SelectedItem);

                UpdateListView(view, dir);
            }
            else if (message)
            {
                MessageBox.Show("Zuerst muss ein Zug ausgewählt werden!", "Zug löschen");
            }
        }
Exemple #19
0
        public ITrain[] GetTrains(Route route, TrainDirection direction)
        {
            var routeStations = (IList <Station>)GetStations(route, direction).ToArray();
            var firstTimes    = new Dictionary <ITrain, TimeEntry>();

            foreach (var t in tt.Trains)
            {
                if (trules.Any(r => r.Matches(t)))
                {
                    continue;
                }

                if (tt.Type == TimetableType.Linear) // Züge in linearen Fahrplänen sind recht einfach
                {
                    if (t.Direction != direction)
                    {
                        continue;
                    }

                    var ardps       = t.GetArrDepsUnsorted();
                    var firstStaion = t.GetPath().FirstOrDefault(a => ardps[a].HasMinOneTimeSet);
                    if (firstStaion == null)
                    {
                        continue; // Something weird happened...
                    }
                    firstTimes.Add(t, ardps[firstStaion].FirstSetTime);
                }
                else
                {
                    var path = t.GetPath();
                    var sortedStopsOnRoute = routeStations
                                             .Intersect(path)
                                             .OrderBy(s => t.GetArrDep(s).FirstSetTime)
                                             .Where(s => t.GetArrDep(s).HasMinOneTimeSet)
                                             .ToArray();

                    if (!sortedStopsOnRoute.Any()) // The train does not stop on this route, ignore.
                    {
                        continue;
                    }

                    if (routeStations.IndexOf(sortedStopsOnRoute.First()) < routeStations.IndexOf(sortedStopsOnRoute.Last()))
                    {
                        var time = t.GetArrDep(sortedStopsOnRoute.First()).FirstSetTime;
                        firstTimes.Add(t, time);
                    } // else: Not needed as routeStations are already sorted according to direction.
                }
            }

            return(firstTimes.Keys.OrderBy(t => firstTimes[t]).ToArray());
        }
Exemple #20
0
        public void SortTrainsName(Timetable tt, TrainDirection dir, bool excludePrefix)
        {
            if (excludePrefix)
            {
                SortTrainsName(tt, dir, false);
            }

            Train[] trains() => tt.Trains.Where(t => t.Direction == dir).ToArray();

            NameParts NameSelector(Train train) => new NameParts(train.TName, excludePrefix);
            bool StringComparer(NameParts cur, NameParts next) => cur.CompareTo(next, excludePrefix);

            InternalSort(tt, trains, NameSelector, StringComparer);
        }
Exemple #21
0
        public void SortTrainsAllStations(Timetable tt, TrainDirection dir, bool topDown)
        {
            var stations = tt.GetStationsOrderedByDirection(dir);

            if (!topDown)
            {
                stations.Reverse();
            }

            foreach (var sta in stations)
            {
                SortTrainsAtStation(tt, dir, sta);
            }
        }
Exemple #22
0
        /// <summary>
        /// Use <see cref="NextTrains"/> to wire up transitions.
        /// This form will NOT wire up transitions itself!
        /// </summary>
        /// <param name="tt"></param>
        /// <param name="direction"></param>
        /// <param name="path"></param>
        public TrainEditForm(Timetable tt, TrainDirection direction, List <Station> path = null) : this(tt)
        {
            Train = new Train(direction, tt);

            if (path != null)
            {
                Train.AddAllArrDeps(path);
            }
            if (tt.Type == TimetableType.Linear)
            {
                Train.AddLinearArrDeps();
            }

            InitializeTrain();
        }
Exemple #23
0
        private Station[] GetStationsInDir(TrainDirection dir)
        {
            if (tt.Type == TimetableType.Linear)
            {
                return(tt.GetStationsOrderedByDirection(dir).ToArray());
            }

            var route = stations.ToList(); // Kopie erzeugen

            if (dir == TrainDirection.ta)
            {
                route.Reverse();
            }

            return(route.ToArray());
        }
Exemple #24
0
        protected void CopyTrain(GridView view, TrainDirection dir, bool message = true)
        {
            if (view.SelectedItem != null)
            {
                var train = (Train)view.SelectedItem;

                using (var tcf = new TrainCopyDialog(train, tt))
                    tcf.ShowModal(this);

                UpdateListView(view, dir);
            }
            else if (message)
            {
                MessageBox.Show("Zuerst muss ein Zug ausgewählt werden!", "Zug kopieren");
            }
        }
Exemple #25
0
        protected void NewTrain(GridView view, TrainDirection direction)
        {
            using (var tef = new TrainEditForm(tt, direction))
            {
                if (tef.ShowModal(this) == DialogResult.Ok)
                {
                    tt.AddTrain(tef.Train);
                    if (tef.NextTrains.Any())
                    {
                        tt.SetTransitions(tef.Train, tef.NextTrains);
                    }

                    UpdateListView(view, direction);
                }
            }
        }
Exemple #26
0
        protected void EditTrain(GridView view, TrainDirection dir, bool message = true)
        {
            if (view.SelectedItem != null)
            {
                Train train = (Train)view.SelectedItem;

                using (var tef = new TrainEditForm(train))
                    if (tef.ShowModal(this) == DialogResult.Ok)
                    {
                        UpdateListView(view, dir);
                    }
            }
            else if (message)
            {
                MessageBox.Show("Zuerst muss ein Zug ausgewählt werden!", "Zug bearbeiten");
            }
        }
Exemple #27
0
        public void SortTrainsAllStations(Timetable tt, TrainDirection dir, bool topDown)
        {
            if (tt.Type != TimetableType.Linear)
            {
                throw new TimetableTypeNotSupportedException(tt.Type, "Sorting at all stations");
            }

            var stations = tt.GetLinearStationsOrderedByDirection(dir);

            if (!topDown)
            {
                stations.Reverse();
            }

            foreach (var sta in stations)
            {
                SortTrainsAtStation(tt, dir, sta);
            }
        }
        public TrainSortDialog(TrainDirection dir, Timetable tt)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            direction = dir;
            this.tt   = tt;

            sortSelection = new SelectionUI <SortSelectionType>(SelectMode, sortSelectionStack);

            stationsComboBox.ItemTextBinding = Binding.Delegate <Station, string>(s => s.SName);
            stationsComboBox.DataStore       = tt.Stations;

            if (dir == TrainDirection.tr) // Netzwerk-Fahrplan
            {
                // deaktiviert "von unten nach oben", "von oben nach unten" in Netzwerk-Fahrplänen
                sortSelection.DisableOption(SortSelectionType.TimeDown);
                sortSelection.DisableOption(SortSelectionType.TimeUp);
            }
        }
Exemple #29
0
        public Train[] GetTrains(Route route, TrainDirection dir)
        {
            var stas  = GetStations(route, dir).ToList();
            var times = new Dictionary <Train, TimeSpan>();

            foreach (var t in TT.Trains)
            {
                if (!trules.All(r => !r.Matches(t)))
                {
                    continue;
                }
                if (TT.Type == TimetableType.Linear) // Züge in linearen Fahrplänen sind recht einfach
                {
                    if (t.Direction != dir)
                    {
                        continue;
                    }

                    var time = t.GetArrDeps().FirstOrDefault(a => a.Value.HasMinOneTimeSet).Value.FirstSetTime;
                    times.Add(t, time);
                    continue;
                }

                var path   = t.GetPath();
                var inters = stas.Intersect(path);
                var stas2  = inters.OrderBy(s => t.GetArrDep(s).FirstSetTime)
                             .Where(s => t.GetArrDep(s).HasMinOneTimeSet);

                if (!stas2.Any())
                {
                    continue;
                }

                if (stas.IndexOf(stas2.First()) < stas.IndexOf(stas2.Last()))
                {
                    var time = t.GetArrDep(stas2.FirstOrDefault()).FirstSetTime;
                    times.Add(t, time);
                }
            }

            return(times.Keys.OrderBy(t => times[t]).ToArray());
        }
Exemple #30
0
        private Station[] GetStationsInDir(TrainDirection dir, Station sta)
        {
            if (tt.Type == TimetableType.Linear)
            {
                var stas = tt.GetLinearStationsOrderedByDirection(dir);
                return(stas.Skip(stas.IndexOf(sta) + 1).ToArray());
            }
            var stasAfter = new List <Station>();

            foreach (var rt in sta.Routes)
            {
                var route        = tt.GetRoute(rt);
                var pos          = sta.Positions.GetPosition(rt);
                var nextStations = dir == TrainDirection.ti ?
                                   route.Stations.Where(s => s.Positions.GetPosition(rt) > pos) : // ti
                                   route.Stations.Where(s => s.Positions.GetPosition(rt) < pos);  // ta
                stasAfter.AddRange(nextStations);
            }
            return(stasAfter.ToArray());
        }
 /// <summary>
 /// 取得本站到到達站的票價資訊
 /// </summary>
 /// <param name="arrival">到達站</param>
 /// <param name="direction">列車方向</param>
 /// <returns>票價資訊</returns>
 public static Fare[] GetFares(this Station THIS, Station arrival, TrainDirection direction) {
     return THIS.GetFaresAsync(arrival, direction).GetAwaiter().GetResult();
 }
Exemple #32
0
 /// <summary>
 /// 非同步取得指定起始站與到達站的票價資訊
 /// </summary>
 /// <param name="starting">起始站</param>
 /// <param name="arrival">到達站</param>
 /// <param name="direction">列車行駛方向</param>
 /// <returns>票價資訊</returns>
 public static async Task<Fare[]> GetFaresAsync(Station starting, Station arrival, TrainDirection direction) {
     return (await GetFaresAsync(starting, arrival)).Where(x => x.Direction == direction).ToArray();
 }
Exemple #33
0
 /// <summary>
 /// 取得指定起始站與到達站的票價資訊
 /// </summary>
 /// <param name="starting">起始站</param>
 /// <param name="arrival">到達站</param>
 /// <param name="direction">列車行駛方向</param>
 /// <returns>票價資訊</returns>
 public static Fare[] GetFares(Station starting, Station arrival, TrainDirection direction) {
     return GetFaresAsync(starting, arrival, direction).GetAwaiter().GetResult();
 }
 /// <summary>
 /// 非同步取得本站到到達站的票價資訊
 /// </summary>
 /// <param name="arrival">到達站</param>
 /// <param name="direction">列車方向</param>
 /// <returns>票價資訊</returns>
 public static async Task<Fare[]> GetFaresAsync(this Station THIS, Station arrival, TrainDirection direction) {
     return await Fare.GetFaresAsync(THIS, arrival, direction);
 }