コード例 #1
0
 /// <summary>
 /// 運休区間を表す文字列から区間情報を返します
 /// </summary>
 /// <example>"運休(小樽-手稲間)</example>
 /// <param name="text">運休区間を表す文字列</param>
 /// <returns>運休区間</returns>
 /// <exception cref="FormatException">運休区間が解釈できない形式のときにスローされる例外。</exception>
 private static LineRange SuspendRangeParser(string text)
 {
     if (text.StartsWith("運休"))
     {
         text = text.Substring(2);
         return(TrainPositionTextParser.GetTrainPosition(text));
     }
     else
     {
         throw new FormatException("運休区間を認識できません。");
     }
 }
コード例 #2
0
 public static TrainData ParseTrainData(RawTrainData rawTrainData, int getedHour, Station station, TrainData.ArrivalTypes arrivalTypes)
 {
     try
     {
         var name        = TrainNameParser.GetTrainName(rawTrainData.TrainName, rawTrainData.TrainType);
         var time        = TrainTimeParser.GetTrainTime(rawTrainData.Time, getedHour);
         var destination = TrainDestParser.GetTrainDestination(rawTrainData.Destination);
         var condition   = TrainConditionParser.GetTrainCondition((TrainData.TrainConditions)rawTrainData.Status, rawTrainData.Addition, rawTrainData.NowPosition);
         var nowPosition = TrainPositionTextParser.GetTrainPosition(rawTrainData.NowPosition);
         return(new TrainData(name, time, station, arrivalTypes, destination, condition, nowPosition));
     }
     catch (Exception ex)
     {
         throw new TrainDataParseException(rawTrainData, "列車データのパースに失敗しました", ex);
     }
 }