public static UserVenueStatistic ParseJson(JToken json)
        {
            var uvs = new UserVenueStatistic();

            uvs.BeenHereMessage = Json.TryGetJsonProperty(json, "beenHereMessage");

            string bh = Json.TryGetJsonProperty(json, "beenHere");
            if (bh != null)
            {
                int i;
                if (int.TryParse(bh, out i))
                {
                    uvs.BeenHere = i;
                }
            }
            
            var v = json["venue"];
            if (v != null)
            {
                var venue = CompactVenue.ParseJson(v);
                if (venue != null)
                {
                    // Overrides!
                    if (!string.IsNullOrEmpty(uvs.BeenHereMessage))
                    {
                        venue.OverrideHereNow(uvs.BeenHereMessage);
                    }

                    uvs.Venue = venue;
                }
            }

            return uvs;
        }
            protected override object DeserializeCore(JObject json, Type objectType, LoadContext context)
            {
                try
                {
                    var b = new UserVenueStats(context);

                    var venues = json["venues"];
                    if (venues != null)
                    {
                        List <UserVenueStatistic> list = new List <UserVenueStatistic>();
                        foreach (var ven in venues)
                        {
                            var v = UserVenueStatistic.ParseJson(ven);
                            if (v != null)
                            {
                                list.Add(v);
                            }
                        }

                        b.FavoriteVenues = list;
                    }

                    var categories = json["categories"];
                    if (categories != null)
                    {
                        List <UserCategoryStatistic> list = new List <UserCategoryStatistic>();
                        foreach (var cat in categories)
                        {
                            var c = UserCategoryStatistic.ParseJson(cat);
                            if (c != null)
                            {
                                list.Add(c);
                            }
                        }

                        b.FavoriteCategories = list;
                    }

                    b.IsLoadComplete = true;

                    return(b);
                }
                catch (Exception e)
                {
                    throw new UserIntendedException(
                              "There was a problem trying to read the venue stats.", e);
                }
            }
示例#3
0
        public static UserVenueStatistic ParseJson(JToken json)
        {
            var uvs = new UserVenueStatistic();

            uvs.BeenHereMessage = Json.TryGetJsonProperty(json, "beenHereMessage");

            string bh = Json.TryGetJsonProperty(json, "beenHere");

            if (bh != null)
            {
                int i;
                if (int.TryParse(bh, out i))
                {
                    uvs.BeenHere = i;
                }
            }

            var v = json["venue"];

            if (v != null)
            {
                var venue = CompactVenue.ParseJson(v);
                if (venue != null)
                {
                    // Overrides!
                    if (!string.IsNullOrEmpty(uvs.BeenHereMessage))
                    {
                        venue.OverrideHereNow(uvs.BeenHereMessage);
                    }

                    uvs.Venue = venue;
                }
            }

            return(uvs);
        }