예제 #1
0
        private void Render(DeparturesMessage message, string fromStationCode, string toStationCode, int firstResults)
        {
            if (!message.Departures.ContainsKey("all"))
            {
                throw new Exception("Departure times not available");
            }

            this.WriteLine("Live Departures");
            this.WriteLine("---------------\n");

            var departures = message.Departures["all"].Take(firstResults);

            foreach (var departure in departures)
            {
                var sb = new StringBuilder();
                sb.Append($"The {departure.ExpectedDepartureTime} to ");
                sb.AppendLine(departure.TerminatingAt);
                sb.Append($"Departing in {departure.ExpectedDepartureInMinutes}");
                sb.Append(departure.ExpectedDepartureInMinutes == 1 ? " minute ": " minutes ");
                sb.AppendLine($"from platform #{departure.Platform}");
                AddRouteTimetable(sb, departure.Route, fromStationCode, toStationCode);
                sb.AppendLine();

                this.WriteLine(sb);
            }
        }
예제 #2
0
 public async Task RenderAsync(DeparturesMessage message, string fromStationCode, string toStationCode, int firstResults)
 {
     await Task.Run(() => Render(message, fromStationCode, toStationCode, firstResults));
 }