public StationInfo[] GetNearestRoute(string fromStationName, int fromLine, string toStationName, int toLine) { StationEntity fromStationEntity; try { fromStationEntity = MetroWebEntity.Instance.StationList[fromStationName, string.Format("{0}号线", fromLine)]; } catch { throw new Exception("From Station is invalid!"); } StationEntity toStationEntity; try { toStationEntity = MetroWebEntity.Instance.StationList[toStationName, string.Format("{0}号线", toLine)]; } catch { throw new Exception("To Station is invalid!"); } RouteFinder finder = new RouteFinder(); var stationLineList = finder.GetTheNearestRouteBetween(fromStationEntity, toStationEntity).Item1; List <StationInfo> stationInfoList = new List <StationInfo>(); foreach (var stationLine in stationLineList) { StationInfo stationInfo = new StationInfoAdapter(stationLine.Station).ToObject(); stationInfoList.Add(stationInfo); } return(stationInfoList.ToArray()); }
public StationInfo[] GetStationInfos() { List <StationEntity> stationEntityList = MetroWebEntity.Instance.StationList.All; List <StationInfo> stationInfoList = new List <StationInfo>(); foreach (StationEntity stationEntity in stationEntityList) { StationInfo stationInfo = new StationInfoAdapter(stationEntity).ToObject(); stationInfoList.Add(stationInfo); } return(stationInfoList.ToArray()); }