public Platform GetPlatformInfo(int PlatformID)
{
Platform Result = new Platform();
//Get the platform info from theGamesDB
XmlDocument ResultXML = new XmlDocument();
WebRequest ResultRequest;
WebResponse ResultResponse;
//Try to reach TheGameDB - return null if this fails (internet connection is not established, GameDB is down, etc.)
try
{
ResultRequest = WebRequest.Create("http://thegamesdb.net/api/GetPlatform.php?id=" + PlatformID);
ResultResponse = ResultRequest.GetResponse();
ResultXML.Load(ResultResponse.GetResponseStream());
}
catch
{
return null;
}
if (ResultXML.InnerXml == "")
return null;
else
{
Result.Name = ResultXML.SelectSingleNode("data/Platform/Platform").InnerText;
Result.Overview = ResultXML.SelectSingleNode("Data/Platform/overview").InnerText;
Result.Developer = ResultXML.SelectSingleNode("Data/Platform/Developer").InnerText;
if (ResultXML.SelectSingleNode("Data/Platform/Images/fanart/original").InnerText != null)
Result.FanartURL = ResultXML.SelectSingleNode("Data/baseImgUrl").InnerText + ResultXML.SelectSingleNode("Data/Platform/Images/fanart/original").InnerText;
if (ResultXML.SelectSingleNode("Data/Platform/Images/boxart").InnerText != null)
Result.BoxartURL = ResultXML.SelectSingleNode("Data/baseImgUrl").InnerText + ResultXML.SelectSingleNode("Data/Platform/Images/boxart").InnerText;
if (ResultXML.SelectSingleNode("Data/Platform/Images/banner").InnerText != null)
Result.BannerURL = ResultXML.SelectSingleNode("Data/baseImgUrl").InnerText + ResultXML.SelectSingleNode("Data/Platform/Images/banner").InnerText;
return Result;
}
}