private static SteamGroup Create(object id, bool fetch, bool cache) { SteamGroup grp; if (!cache) { grp = new SteamGroup(id); } else if (!IsCached(id)) { grp = new SteamGroup(id); cacheMemory[id] = grp; } else { grp = cacheMemory[id]; } if (fetch && !grp.IsFetched) { grp.FetchMembers(cache); } return(grp); }
public static SteamGroup Create(string id, bool fetch, bool cache) { return(SteamGroup.Create((object)id.ToLower(), fetch, cache)); }
public static SteamGroup Create(long id, bool fetch, bool cache) { return(SteamGroup.Create((object)id, fetch, cache)); }
public static SteamGroup Create(string id, bool fetch) { return(SteamGroup.Create(id, fetch, true)); }
public static SteamGroup Create(string id) { return(SteamGroup.Create(id, true, true)); }
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; }