Ejemplo n.º 1
0
        /// <summary>
        /// Gets all the games for a platform.
        /// </summary>
        /// <param name="platform">The platform to return games for</param>
        /// <returns>A collection of all the games on the platform</returns>
        public static ICollection <GameSearchResult> GetPlatformGames(PlatformSearchResult platform)
        {
            ICollection <GameSearchResult> games = GetPlatformGames(platform.ID);

            foreach (GameSearchResult game in games)
            {
                game.Platform = platform.Name;
            }
            return(games);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a collection of all the available platforms.
        /// </summary>
        /// <returns>A collection of all the available platforms</returns>
        public static ICollection <PlatformSearchResult> GetPlatforms()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(@"http://thegamesdb.net/api/GetPlatformsList.php");

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

            List <PlatformSearchResult> platforms = new List <PlatformSearchResult>();

            // Iterate through all platforms
            XmlNode platformNode;

            while (ienum.MoveNext())
            {
                platformNode = (XmlNode)ienum.Current;

                PlatformSearchResult platform = new PlatformSearchResult();

                IEnumerator ienumPlatform = platformNode.GetEnumerator();
                XmlNode     attributeNode;
                while (ienumPlatform.MoveNext())
                {
                    attributeNode = (XmlNode)ienumPlatform.Current;

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

                    case "name":
                        platform.Name = attributeNode.InnerText;
                        break;

                    case "alias":
                        platform.Alias = attributeNode.InnerText;
                        break;
                    }
                }

                platforms.Add(platform);
            }

            return(platforms);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets all the games for a platform.
 /// </summary>
 /// <param name="platform">The platform to return games for</param>
 /// <returns>A collection of all the games on the platform</returns>
 public static ICollection<GameSearchResult> GetPlatformGames(PlatformSearchResult platform) {
     ICollection<GameSearchResult> games = GetPlatformGames(platform.ID);
     foreach (GameSearchResult game in games) {
         game.Platform = platform.Name;
     }
     return games;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets all data for a specific platform.
 /// </summary>
 /// <param name="platform">The platform to return data for (can be found by using GetPlatformsList)</param>
 /// <returns>A Platform-object containing all the data about the platform, or null if no platform was found</returns>
 public static Platform GetPlatform(PlatformSearchResult platform) {
     return GetPlatform(platform.ID);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a collection of all the available platforms.
        /// </summary>
        /// <returns>A collection of all the available platforms</returns>
        public static ICollection<PlatformSearchResult> GetPlatforms() {
            XmlDocument doc = new XmlDocument();
            doc.Load(@"http://thegamesdb.net/api/GetPlatformsList.php");

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

            List<PlatformSearchResult> platforms = new List<PlatformSearchResult>();

            // Iterate through all platforms
            XmlNode platformNode;
            while (ienum.MoveNext()) {
                platformNode = (XmlNode)ienum.Current;

                PlatformSearchResult platform = new PlatformSearchResult();

                IEnumerator ienumPlatform = platformNode.GetEnumerator();
                XmlNode attributeNode;
                while (ienumPlatform.MoveNext()) {
                    attributeNode = (XmlNode)ienumPlatform.Current;

                    // Iterate through all platform attributes
                    switch (attributeNode.Name) {
                        case "id":
                            int.TryParse(attributeNode.InnerText, out platform.ID);
                            break;
                        case "name":
                            platform.Name = attributeNode.InnerText;
                            break;
                        case "alias":
                            platform.Alias = attributeNode.InnerText;
                            break;
                    }
                }

                platforms.Add(platform);
            }

            return platforms;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets all data for a specific platform.
 /// </summary>
 /// <param name="platform">The platform to return data for (can be found by using GetPlatformsList)</param>
 /// <returns>A Platform-object containing all the data about the platform, or null if no platform was found</returns>
 public static Platform GetPlatform(PlatformSearchResult platform)
 {
     return(GetPlatform(platform.ID));
 }