示例#1
0
        // Queries all the verbose owned game information of a player.
        public static VerboseOwnedGameInfo[] Query(string apikey, long playerId, bool includeFreeGames)
        {
            int freeGamesInt = 0;

            if (includeFreeGames)
            {
                freeGamesInt = 1;
            }

            string    url = String.Format("http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={0}&steamid={1}&include_played_free_games={2}&include_appinfo=1&format=xml", apikey, playerId, freeGamesInt);
            XDocument xml = GetXML(url);

            if (xml == null)
            {
                return(new VerboseOwnedGameInfo[0]);
            }

            XElement[]             items  = xml.Descendants("message").ToArray();
            VerboseOwnedGameInfo[] result = new VerboseOwnedGameInfo[items.Length];

            for (int i = 0; i < items.Length; ++i)
            {
                result[i] = Parse(items[i]);
            }

            return(result);
        }
示例#2
0
        // Parses the xml formatted verbose owned game info to an object.
        private static VerboseOwnedGameInfo Parse(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser        parser = new ElementParser(xml);
            VerboseOwnedGameInfo result = new VerboseOwnedGameInfo
            {
                AppId          = parser.GetAttributeInteger("appid"),
                TotalPlayTime  = parser.GetAttributeInteger("playtime_forever"),
                RecentPlayTime = parser.GetAttributeInteger("playtime_2weeks"),
                Title          = parser.GetAttributeString("name"),
                Icon           = parser.GetAttributeString("img_icon_url"),
                Logo           = parser.GetAttributeString("img_logo_url"),
                HasGameStats   = parser.GetAttributeBoolean("has_community_visible_stats")
            };

            if (result.RecentPlayTime == -1)
            {
                result.RecentPlayTime = 0;
            }

            return(result);
        }
示例#3
0
        // Queries all the verbose owned game information of recently played games of a player.
        public static VerboseOwnedGameInfo[] QueryRecent(string apikey, long playerId, int count)
        {
            string    url = String.Format("http://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v0001/?key={0}&steamid={1}&count={2}&format=xml", apikey, playerId, count);
            XDocument xml = GetXML(url);

            if (xml == null)
            {
                return(new VerboseOwnedGameInfo[0]);
            }

            XElement[]             items  = xml.Descendants("message").ToArray();
            VerboseOwnedGameInfo[] result = new VerboseOwnedGameInfo[items.Length];

            for (int i = 0; i < items.Length; ++i)
            {
                result[i] = Parse(items[i]);
            }

            return(result);
        }