Exemple #1
0
        internal async Task <Dictionary <uint, string> > GetOwnedGames()
        {
            if (!await RefreshSessionIfNeeded().ConfigureAwait(false))
            {
                return(null);
            }

            string request = SteamCommunityURL + "/my/games/?xml=1";

            XmlDocument response = await WebBrowser.UrlGetToXMLRetry(request).ConfigureAwait(false);

            if (response == null)
            {
                return(null);
            }

            XmlNodeList xmlNodeList = response.SelectNodes("gamesList/games/game");

            if ((xmlNodeList == null) || (xmlNodeList.Count == 0))
            {
                return(null);
            }

            Dictionary <uint, string> result = new Dictionary <uint, string>(xmlNodeList.Count);

            foreach (XmlNode xmlNode in xmlNodeList)
            {
                XmlNode appNode = xmlNode.SelectSingleNode("appID");
                if (appNode == null)
                {
                    Logging.LogNullError(nameof(appNode), Bot.BotName);
                    continue;
                }

                uint appID;
                if (!uint.TryParse(appNode.InnerText, out appID))
                {
                    Logging.LogNullError(nameof(appID), Bot.BotName);
                    continue;
                }

                XmlNode nameNode = xmlNode.SelectSingleNode("name");
                if (nameNode == null)
                {
                    Logging.LogNullError(nameof(nameNode), Bot.BotName);
                    continue;
                }

                result[appID] = nameNode.InnerText;
            }

            return(result);
        }