protected override GetTeamInfoByTeamIDResponseTeam Create(Type objectType, JObject jsonObject)
        {
            var team = new GetTeamInfoByTeamIDResponseTeam();

            team.TeamID      = long.Parse(jsonObject["team_id"].ToNullableString());
            team.Name        = jsonObject["name"].ToNullableString();
            team.Tag         = jsonObject["tag"].ToNullableString();
            team.TimeCreated = long.Parse(jsonObject["time_created"].ToNullableString()).ToDateTime();
            team.Rating      = jsonObject["rating"].ToNullableString();
            team.Logo        = long.Parse(jsonObject["logo"].ToNullableString());
            team.LogoSponsor = long.Parse(jsonObject["logo_sponsor"].ToNullableString());
            team.CountryCode = jsonObject["country_code"].ToNullableString();
            team.Url         = jsonObject["url"].ToNullableString();
            team.GamesPlayedWithCurrentRoster =
                int.Parse(jsonObject["games_played_with_current_roster"].ToNullableString());
            team.AdminIdentity =
                SteamIdentity.FromAccountID(long.Parse(jsonObject["admin_account_id"].ToNullableString()));
            team.PlayerIdentities = new List <SteamIdentity>();
            team.Leagues          = new List <GetTeamInfoByTeamIDResponseLeague>();

            var playerAccountIDs = jsonObject.Properties().Where(x => x.Name.Contains("player_"));

            foreach (var playerAccountID in playerAccountIDs)
            {
                team.PlayerIdentities.Add(
                    SteamIdentity.FromAccountID(long.Parse(playerAccountID.Value.ToNullableString())));
            }

            var leagueIDs = jsonObject.Properties().Where(x => x.Name.Contains("league_id"));

            foreach (var leagueID in leagueIDs)
            {
                team.Leagues.Add(new GetTeamInfoByTeamIDResponseLeague
                {
                    LeagueID = long.Parse(leagueID.Value.ToNullableString())
                });
            }

            return(team);
        }
コード例 #2
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
                                 JsonSerializer serializer)
 {
     return(SteamIdentity.FromAccountID(long.Parse(reader.Value.ToNullableString())));
 }