Ejemplo n.º 1
0
        /// <summary>
        /// Gets all data for a specific platform.
        /// </summary>
        /// <param name="ID">The platform ID 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 GDBNETPlatform GetPlatform(int ID)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(@"http://thegamesdb.net/api/GetPlatform.php?id=" + ID);

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

            XmlNode        platformNode = root.FirstChild.NextSibling;
            GDBNETPlatform platform     = new GDBNETPlatform();

            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 "Platform":
                    platform.Name = attributeNode.InnerText;
                    break;

                case "overview":
                    platform.Overview = attributeNode.InnerText;
                    break;

                case "developer":
                    platform.Developer = attributeNode.InnerText;
                    break;

                case "manufacturer":
                    platform.Manufacturer = attributeNode.InnerText;
                    break;

                case "cpu":
                    platform.CPU = attributeNode.InnerText;
                    break;

                case "memory":
                    platform.Memory = attributeNode.InnerText;
                    break;

                case "graphics":
                    platform.Graphics = attributeNode.InnerText;
                    break;

                case "sound":
                    platform.Sound = attributeNode.InnerText;
                    break;

                case "display":
                    platform.Display = attributeNode.InnerText;
                    break;

                case "media":
                    platform.Media = attributeNode.InnerText;
                    break;

                case "maxcontrollers":
                    int.TryParse(attributeNode.InnerText, out platform.MaxControllers);
                    break;

                case "Rating":
                    float.TryParse(attributeNode.InnerText, out platform.Rating);
                    break;

                case "Images":
                    platform.Images.FromXmlNode(attributeNode);
                    break;
                }
            }

            return(platform);
        }