本文整理汇总了C#中Train.IsTrainDelayed方法的典型用法代码示例。如果您正苦于以下问题:C# Train.IsTrainDelayed方法的具体用法?C# Train.IsTrainDelayed怎么用?C# Train.IsTrainDelayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Train
的用法示例。
在下文中一共展示了Train.IsTrainDelayed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
int count;
string trainKey;
string station;
string stationName;
string route;
string destination;
string direction;
string estArrivalTime;
string runNumber;
int isDelayed;
int isArriving;
List<Train> trains = new List<Train>();
//Add your CTA API key here
trainKey = null;
//Add station here, CTA dev documentation has full list
station = "30109";
string type;
if (station.Substring(0, 1) == "4")
type = "mapid";
else
type = "stpid";
//Imports XML data.
XmlDocument APIDoc = null;
XmlTextReader reader = new XmlTextReader("http://lapi.transitchicago.com/api/1.0/ttarrivals.aspx?key=" + trainKey + "&" + type + "=" + station);
APIDoc = new XmlDocument();
APIDoc.Load(reader);
count = APIDoc.ChildNodes[1].SelectNodes("eta").Count;
reader.Close();
//Extracts data from XML and stroes in a Train object
for (int i = 3; i < count + 2; i++)
{
stationName = APIDoc.ChildNodes[1].ChildNodes[i].ChildNodes[2].ChildNodes[0].Value;
route = APIDoc.ChildNodes[1].ChildNodes[i].ChildNodes[5].ChildNodes[0].Value;
destination = APIDoc.ChildNodes[1].ChildNodes[i].ChildNodes[3].ChildNodes[0].Value;
direction = APIDoc.ChildNodes[1].ChildNodes[i].ChildNodes[8].ChildNodes[0].Value;
estArrivalTime = APIDoc.ChildNodes[1].ChildNodes[i].ChildNodes[10].ChildNodes[0].Value;
runNumber = APIDoc.ChildNodes[1].ChildNodes[i].ChildNodes[4].ChildNodes[0].Value;
isDelayed = Convert.ToInt32(APIDoc.ChildNodes[1].ChildNodes[i].ChildNodes[13].ChildNodes[0].Value);
isArriving = Convert.ToInt32(APIDoc.ChildNodes[1].ChildNodes[i].ChildNodes[11].ChildNodes[0].Value);
Train train = new Train(stationName, route, destination, direction, runNumber);
train.Route = train.RouteNameConversion(route);
train.IsDelayed = train.IsTrainDelayed(isDelayed);
train.IsArriving = train.IsTrainArriving(isArriving);
train.ArrivalInMinutes = train.CalculateMinutesToArrival(estArrivalTime);
train.PrintString = train.PrintData();
trains.Add(train);
}
WriteListToConsole(trains);
//WriteNextTrainToConsole(trains);
Console.ReadLine();
}