Пример #1
0
 /// <summary>
 /// Connections between the specified stations at the given moment.
 /// The moment can either be the time of arrival or the time of departure.
 /// </summary>
 /// <param name='fromStation'>
 /// FThe station of departure.
 /// </param>
 /// <param name='destinationStation'>
 /// The station of destination.
 /// </param>
 /// <param name='TimeType'>
 /// The type of the time. Passing NMBSTimeSelection.DepartureTime will force the specified
 /// moment to be interpreted as the time of departure, specifying NMBSTimeSelection.ArrivalTime 
 /// will mark the moment specified as the time of arrival.
 /// </param>
 /// <param name='moment'>
 /// The time and date to which the data should be applicable.
 /// </param>
 public IList<Connection> Connections(Station fromStation, Station destinationStation, NMBSTimeSelection timeType, DateTime moment)
 {
     var doc = XDocument.Parse(ConnectionXML(Language.ToString(), fromStation.Name, destinationStation.Name, moment, timeType));
     return _parseConnections(doc);
 }
Пример #2
0
 /// <summary>
 /// Fetches the raw XML for the connections for the specified route.
 /// </summary>
 /// <returns>
 /// The XML code generated by the server.
 /// </returns>
 /// <param name='lang'>
 /// The language for the data.
 /// </param>
 /// <param name='fromStation'>
 /// The station of departure
 /// </param>
 /// <param name='toStation'>
 /// The station of (planned) arrival
 /// </param>
 /// <param name='momentOfDeparture'>
 /// Moment of departure.
 /// </param>
 private string ConnectionXML(string lang, string fromStation, string toStation, DateTime momentOfDeparture, NMBSTimeSelection timeSelection)
 {
     WebClient client = new WebClient();
     return client.DownloadString(String.Format("{0}/{1}/?lang={2}&to={3}&from={4}&date={5:ddMMyy}&time={6:HHmm}&timeSel={7}", BaseUrl, "connections", lang, toStation,
                                                fromStation, momentOfDeparture, momentOfDeparture,
                                                timeSelection == NMBSTimeSelection.DepartureTime ? "depart" : "arrive"
                                                ));
 }