コード例 #1
0
ファイル: GDBNETGamesDB.cs プロジェクト: newton9278/MedLaunch
        /// <summary>
        /// Gets a collection of games matched up with loose search terms.
        /// </summary>
        /// <param name="Name">The game title to search for</param>
        /// <param name="Platform">Filters results by platform</param>
        /// <param name="Genre">Filters results by genre</param>
        /// <returns>A collection of games that matched the search terms</returns>
        public static ICollection <GDBNETGameSearchResult> GetGames(String Name, String Platform = "", String Genre = "")
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(@"http://thegamesdb.net/api/GetGamesList.php?name=" + Name + @"&platform=" + Platform + @"&genre=" + Genre);

            XmlNode     root  = doc.DocumentElement;
            IEnumerator ienum = root.GetEnumerator();

            List <GDBNETGameSearchResult> games = new List <GDBNETGameSearchResult>();

            // Iterate through all games
            XmlNode gameNode;

            while (ienum.MoveNext())
            {
                GDBNETGameSearchResult game = new GDBNETGameSearchResult();
                gameNode = (XmlNode)ienum.Current;

                IEnumerator ienumGame = gameNode.GetEnumerator();
                XmlNode     attributeNode;
                while (ienumGame.MoveNext())
                {
                    attributeNode = (XmlNode)ienumGame.Current;

                    // Iterate through all game attributes
                    switch (attributeNode.Name)
                    {
                    case "id":
                        int.TryParse(attributeNode.InnerText, out game.ID);
                        break;

                    case "GameTitle":
                        game.Title = attributeNode.InnerText;
                        break;

                    case "ReleaseDate":
                        game.ReleaseDate = attributeNode.InnerText;
                        break;

                    case "Platform":
                        game.Platform = attributeNode.InnerText;
                        break;
                    }
                }

                games.Add(game);
            }

            return(games);
        }
コード例 #2
0
ファイル: GDBNETGamesDB.cs プロジェクト: newton9278/MedLaunch
        /// <summary>
        /// Gets all the games for a platform. The Platform field will not be filled.
        /// </summary>
        /// <param name="ID">The platform ID to return games for (can be found by using GetPlatformsList)</param>
        /// <returns>A collection of all the games on the platform</returns>
        public static ICollection <GDBNETGameSearchResult> GetPlatformGames(int ID)
        {
            WebOps wo = new WebOps();

            wo.Params  = "/GetPlatformGames.php?platform=" + ID;
            wo.Timeout = 20000;
            string result = wo.ApiCall();

            // string returned
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(result);

            /*
             * XmlDocument doc = new XmlDocument();
             * try
             * {
             *  doc.Load(@"http://thegamesdb.net/api/GetPlatformGames.php?platform=" + ID);
             * }
             * catch (Exception ex)
             * {
             *  return new List<GDBNETGameSearchResult>();
             * }
             * finally { }
             */

            XmlNode     root  = doc.DocumentElement;
            IEnumerator ienum = root.GetEnumerator();

            List <GDBNETGameSearchResult> games = new List <GDBNETGameSearchResult>();

            // Iterate through all games
            XmlNode gameNode;

            while (ienum.MoveNext())
            {
                GDBNETGameSearchResult game = new GDBNETGameSearchResult();
                gameNode = (XmlNode)ienum.Current;

                IEnumerator ienumGame = gameNode.GetEnumerator();
                XmlNode     attributeNode;
                while (ienumGame.MoveNext())
                {
                    attributeNode = (XmlNode)ienumGame.Current;

                    // Iterate through all game attributes
                    switch (attributeNode.Name)
                    {
                    case "id":
                        int.TryParse(attributeNode.InnerText, out game.ID);
                        break;

                    case "GameTitle":
                        game.Title = attributeNode.InnerText;
                        break;

                    case "ReleaseDate":
                        game.ReleaseDate = attributeNode.InnerText;
                        break;
                    }
                }

                games.Add(game);
            }

            return(games);
        }
コード例 #3
0
ファイル: GDBNETGamesDB.cs プロジェクト: newton9278/MedLaunch
 /// <summary>
 /// Gets the data for a specific game.
 /// </summary>
 /// <param name="game">The game to return data for</param>
 /// <returns>A Game-object containing all the data about the game, or null if no game was found</returns>
 public static GDBNETGame GetGame(GDBNETGameSearchResult game)
 {
     return(GetGame(game.ID));
 }