API.TransitManager.GetEtas C# (CSharp) Метод

GetEtas() публичный статический Метод

Gets the ETA info for a set of stop IDS. The outer dictionary takes a route number and gives a dictionary that takes a stop ID to an ETA.
public static GetEtas ( ITransitRepository repository, ITransitClient client, IEnumerable stopIds ) : Task
repository ITransitRepository
client ITransitClient
stopIds IEnumerable
Результат Task
        public static async Task<BusArrivalEstimates> GetEtas(ITransitRepository repository, ITransitClient client, IEnumerable<int> stopIds)
        {
            var toPlatformTag = await repository.GetPlatformTagsAsync();
            
            Func<int, Task<Tuple<int, ConnexionzPlatformET>>> getEtaIfTagExists =
                async id => Tuple.Create(id, toPlatformTag.ContainsKey(id) ? await client.GetEta(toPlatformTag[id]) : null);

            var tasks = stopIds.Select(getEtaIfTagExists);
            var results = await Task.WhenAll(tasks);

            return results.ToDictionary(eta => eta.Item1,
                eta => eta.Item2?.RouteEstimatedArrivals
                                ?.ToDictionary(routeEta => routeEta.RouteNo,
                                               routeEta => routeEta.EstimatedArrivalTime)
                       ?? new Dictionary<string, List<int>>());
        }