// TODO: Scores and total from this entry... see how official app does it. public LeaderboardNotification(JToken item) { Message = Checkin.SanitizeString(Json.TryGetJsonProperty(item, "message")); var leaders = new List <LeaderboardItem>(); var lj = item["leaderboard"]; if (lj != null) { foreach (var victor in lj) { var wolverine = LeaderboardItem.ParseJson(victor); if (wolverine != null) { leaders.Add(wolverine); } } } Leaderboard = leaders; }
/// <summary> /// Parses the JSON response to retrieve the leaderboard, parsing /// of individual items are handled by their compact object /// parse routines. /// </summary> protected override object DeserializeCore(JObject json, Type objectType, LeaderboardLoadContext context) { try { var nv = new Leaderboard(context); var results = json["leaderboard"]; var b = new List <LeaderboardItem>(); if (results != null) { var items = results["items"]; if (items != null) { foreach (var entry in items) { var u = LeaderboardItem.ParseJson(entry); if (u != null) { b.Add(u); } } } } nv.Board = b; nv.IsLoadComplete = true; return(nv); } catch (Exception e) { throw new UserIntendedException( "The leaderboard could not be refreshed right now.", e); } }