示例#1
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);
        }
示例#2
0
        // Parse xml formatted news article to an object.
        private static NewsArticle Parse(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser parser = new ElementParser(xml);
            NewsArticle   result = new NewsArticle
            {
                Gid        = parser.GetAttributeLong("gid"),
                AppId      = parser.GetAttributeInteger("appid"),
                Title      = parser.GetAttributeString("title"),
                Url        = parser.GetAttributeString("url"),
                Content    = parser.GetAttributeString("contents"),
                Author     = parser.GetAttributeString("author"),
                FeedLabel  = parser.GetAttributeString("feedlabel"),
                FeedType   = parser.GetAttributeString("feed_type"),
                FeedName   = parser.GetAttributeString("feedname"),
                Date       = parser.GetAttributeDate("date"),
                IsExternal = parser.GetAttributeBoolean("is_external_url")
            };

            return(result);
        }
        // Parses player summaries.
        private static PlayerSummary Parse(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser parser = new ElementParser(xml);
            PlayerSummary result = new PlayerSummary
            {
                Id             = parser.GetAttributeLong("steamid"),
                DisplayName    = parser.GetAttributeString("personaname"),
                Url            = parser.GetAttributeString("profileurl"),
                AvatarSmall    = parser.GetAttributeString("avatar"),
                AvatarMedium   = parser.GetAttributeString("avatarmedium"),
                AvatarLarge    = parser.GetAttributeString("avatarfull"),
                Status         = parser.GetAttributeInteger("personastate"),
                Visibility     = parser.GetAttributeInteger("communityvisibilitystate"),
                Configured     = parser.GetAttributeBoolean("profilestate"),
                LastSeen       = parser.GetAttributeDate("lastlogoff"),
                AllowsComments = parser.GetAttributeBoolean("commentpermission"),
                Name           = parser.GetAttributeString("realname"),
                PrimaryClan    = parser.GetAttributeLong("primaryclanid"),
                CreationDate   = parser.GetAttributeDate("timecreated"),
                AppId          = parser.GetAttributeInteger("gameid"),
                AppInfo        = parser.GetAttributeString("gameextrainfo"),
                ServerIp       = parser.GetAttributeIpAdress("gameserverip"),
                ServerPort     = parser.GetAttributePort("gameserverip"),
                CityId         = parser.GetAttributeInteger("loccityid"),
                Country        = parser.GetAttributeString("loccountrycode"),
                State          = parser.GetAttributeString("locstatecode")
            };

            return(result);
        }
        // Parse player shared game owner.
        private static long GetSharedGameOwner(string apikey, long playerId, int appId)
        {
            string        url    = String.Format("http://api.steampowered.com/IPlayerService/IsPlayingSharedGame/v0001/?key={0}&steamid={1}&appid_playing={2}&format=xml", apikey, playerId, appId);
            XDocument     xml    = GetXML(url);
            ElementParser parser = new ElementParser(xml.Element("response"));

            return(parser.GetAttributeInteger("lender_steamid"));
        }
示例#5
0
        // Parses id getter results.
        private static long Parse(XElement xml)
        {
            if (xml == null)
            {
                return(-1);
            }

            ElementParser parser = new ElementParser(xml);

            return(parser.GetAttributeLong("steamid"));
        }
示例#6
0
        // Parses xml formatted achievement percentages to an object.
        public static Tuple <string, double> ParseAchievementPercentage(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser parser = new ElementParser(xml);

            Tuple <string, double> result = new Tuple <string, double>(parser.GetAttributeString("name"), parser.GetAttributeDouble("percent"));

            return(result);
        }
        // Parse xml formatted statistic to an object.
        private static PlayerStatistic Parse(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser   parser = new ElementParser(xml);
            PlayerStatistic result = new PlayerStatistic
            {
                Name  = parser.GetAttributeString("name"),
                Value = parser.GetAttributeInteger("value")
            };

            return(result);
        }
示例#8
0
        // Parse xml formatted statistic to an object.
        public static Statistic Parse(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser parser = new ElementParser(xml);
            Statistic     result = new Statistic
            {
                Name         = parser.GetAttributeString("name"),
                DisplayName  = parser.GetAttributeString("displayName"),
                DefaultValue = parser.GetAttributeInteger("defaultvalue")
            };

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

            ElementParser parser = new ElementParser(xml);

            Friend result = new Friend
            {
                Id           = parser.GetAttributeLong("steamid"),
                Date         = parser.GetAttributeDate("friend_since"),
                Relationship = GetRelationshipInt(parser.GetAttributeString("relationship"))
            };

            return(result);
        }
示例#10
0
        // Parse xml formatted game to an object.
        private static Game Parse(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser parser = new ElementParser(xml);
            Game          result = new Game
            {
                Title        = parser.GetAttributeString("gameName"),
                Version      = parser.GetAttributeInteger("gameVersion"),
                Achievements = ParseAchievements(xml),
                Statistics   = ParseStatistics(xml)
            };

            return(result);
        }
示例#11
0
        // Parses player bans
        private static PlayerBanInfo Parse(XElement xml)
        {
            if (xml == null)
            {
                return(new PlayerBanInfo());
            }

            ElementParser parser = new ElementParser(xml);
            PlayerBanInfo result = new PlayerBanInfo
            {
                HasVACBan        = parser.GetAttributeBoolean("VACBanned"),
                HasCommunityBan  = parser.GetAttributeBoolean("CommunityBanned"),
                HasTradeBan      = parser.GetAttributeBoolean("EconomyBan"),
                VACBanCount      = parser.GetAttributeInteger("NumberOfVACBans"),
                GameBanCount     = parser.GetAttributeInteger("NumberOfGameBans"),
                DaysSinceLastBan = parser.GetAttributeInteger("DaysSinceLastBan")
            };

            return(result);
        }
示例#12
0
        // Parse xml formatted achievement to an object.
        public static Achievement Parse(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser parser = new ElementParser(xml);
            Achievement   result = new Achievement
            {
                Name         = parser.GetAttributeString("name"),
                DisplayName  = parser.GetAttributeString("displayName"),
                DefaultValue = parser.GetAttributeInteger("defaultvalue"),
                Hidden       = parser.GetAttributeBoolean("hidden"),
                Description  = parser.GetAttributeString("description"),
                Icon         = parser.GetAttributeString("icon"),
                LockedIcon   = parser.GetAttributeString("icongray")
            };

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

            ElementParser parser = new ElementParser(xml);
            OwnedGameInfo result = new OwnedGameInfo
            {
                AppId          = parser.GetAttributeInteger("appid"),
                TotalPlayTime  = parser.GetAttributeInteger("playtime_forever"),
                RecentPlayTime = parser.GetAttributeInteger("playtime_2weeks")
            };

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

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

            ElementParser parser = new ElementParser(xml);

            if (!parser.GetAttributeBoolean("achieved"))
            {
                return(null);
            }

            PlayerAchievement result = new PlayerAchievement
            {
                Name = parser.GetAttributeString("apiname"),
                Date = parser.GetAttributeDate("unlocktime")
            };

            return(result);
        }