Exemplo n.º 1
0
        /// <summary>
        /// Kitacaエリア外の一括形式の駅データを読み取ります。
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static async Task <TrainDataFile[]> GetSpecialTrainDatasAsync(int id)
        {
            var data = await TrainDataGeter.GetTrainDataJsonAsync(id);

            return(await Task.Run(() =>
            {
                var rawTrainDataFiles = JsonDeserializer.DeserializeSpecialTrainInfo(data);
                return rawTrainDataFiles.Select(rstd => TrainFilePaeser.ParseRawTrainDataFile(rstd)).ToArray();
            }));
        }
Exemplo n.º 2
0
        internal static async Task <TrainDataFile> GetSpecialTrainDataAsync(Station station)
        {
            var data = await TrainDataGeter.GetTrainDataJsonAsync(station.StationArea);

            return(await Task.Run(() =>
            {
                var rawTrainDataFiles = JsonDeserializer.DeserializeSpecialTrainInfo(data);
                return TrainFilePaeser.ParseRawTrainDataFile(rawTrainDataFiles.First(rtdf => rtdf.StationId == station.StationId));
            }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 駅 ID を指定して列車情報を取得します。エリア外の駅の場合広域データから列車情報を返します。
        /// </summary>
        /// <param name="id">取得対象の駅 ID。</param>
        /// <returns>解析済みの列車情報。</returns>
        public static async Task <TrainDataFile> GetTrainDataAsync(int id)
        {
            var station = StationReader.GetStationById(id);

            if (station.StationArea != 0)
            {
                return(await GetSpecialTrainDataAsync(station));
            }

            var data = await TrainDataGeter.GetTrainDataJsonAsync(id);

            return(await Task.Run(() =>
            {
                var rawTrainDataFile = JsonDeserializer.DeserializeTrainInfo(data);
                return TrainFilePaeser.ParseRawTrainDataFile(rawTrainDataFile);
            }));
        }
Exemplo n.º 4
0
 public static async Task <string> GetTrainDataJsonAsync(int id)
 {
     return(await TrainDataGeter.GetTrainDataJsonAsync(id));
 }