public void FetchData(bool cache)
        {
            try {
                XmlDocument profile = new XmlDocument();
                profile.LoadUrl(BaseUrl + "?xml=1");

                // TODO: check for error, throw exception

                Nickname        =                profile.GetInnerText("steamID");
                SteamID64       =     long.Parse(profile.GetInnerText("steamID64"));
                VacBanned       =                profile.GetInnerText("vacBanned").Equals("1");
                ImageUrl        =                profile.GetInnerText("avatarIcon");
                OnlineState     =                profile.GetInnerText("onlineState");
                PrivacyState    =                profile.GetInnerText("privacyState");
                StateMessage    =                profile.GetInnerText("stateMessage");
                VisibilityState =      int.Parse(profile.GetInnerText("visibilityState"));
                Headline        =                profile.GetInnerText("headline");
                HoursPlayed     =    float.Parse(profile.GetInnerText("hoursPlayed2Wk"));
                Location        =                profile.GetInnerText("location");
                MemberSince     = DateTime.Parse(profile.GetInnerText("memberSince"));
                Realname        =                profile.GetInnerText("realname");
                SteamRating     =    float.Parse(profile.GetInnerText("steamRating"));
                Summary         =                profile.GetInnerText("summary");

                if (profile.GetElementsByTagName("privacyMessage").Count > 0)
                    throw new SteamCondenserException(profile.GetInnerText("privacyMessage"));

                if (PrivacyState == "public") {
                    CustomUrl = profile.GetInnerText("customURL");
                    if (CustomUrl.Length == 0) CustomUrl = null;
                    else Cache();
                }

                var favGame = profile.GetElementsByTagName("favoriteGame").Item(0);
                if (favGame != null)
                {
                    // TODO: implement this
                }

                var mostPlayedGamesNode = profile.GetElementsByTagName("mostPlayedGames").Item(0);
                MostPlayedGames = new Dictionary<string, float>();
                if (mostPlayedGamesNode != null) {
                    foreach (XmlElement node in mostPlayedGamesNode) {
                        string gameName   =             node.GetInnerText("gameName");
                        float hoursPlayed = float.Parse(node.GetInnerText("hoursPlayed"));
                        MostPlayedGames.Add(gameName, hoursPlayed);
                    }
                }

                var groupsNode = profile.GetElementsByTagName("groups").Item(0);
                if (groupsNode != null) {
                    List<SteamGroup> grps = new List<SteamGroup>();
                    foreach (XmlElement node in groupsNode) {
                        grps.Add(SteamGroup.Create(long.Parse(node.GetInnerText("groupID64")), false));
                    }
                    Groups = grps.ToArray();
                }

                var weblinksNode = profile.GetXmlElement("weblinks");
                if (weblinksNode != null) {
                    Links = new Dictionary<string, string>();
                    if (groupsNode != null) {
                        foreach (XmlElement node in weblinksNode) {
                            string title = node.GetInnerText("title");
                            string link  = node.GetInnerText("link");
                            Links.Add(title, link);
                        }
                    }
                } else { }
            } catch (XmlException) {
                throw new SteamCondenserException("XML data could not be parsed.");
            }
            FetchTime = DateTime.Now;
        }
        public long[] GetFriendsIDs()
        {
            XmlDocument page = new XmlDocument();
            page.LoadUrl(BaseUrl + "/friends?xml=1");

            var friends = page.GetElementsByTagName("friends").Item(0);

            long[] friendids = new long[friends.ChildNodes.Count];
            for (int i = 0; i < friends.ChildNodes.Count; i++) {
                friendids[i] = long.Parse(friends.ChildNodes[i].InnerText);
            }
            return friendids;
        }
Example #3
0
        protected GameStats(long steamid, string gamename)
        {
            SteamID64 = steamid;

            ShortGameName = gamename;

            doc = new XmlDocument();
            doc.LoadUrl(BaseUrl);
            FetchData();
        }