public Venue(Dictionary<string, object> jsonDictionary) : base(jsonDictionary) { Photos = ""; SpecialsNearby = new List<Special>(); Tags = new List<string>(); Todos = new List<ToDo>(); Tips = new Dictionary<string, List<Tip>>(); Specials = new List<Special>(); Categories = new List<Category>(); jsonDictionary = Helpers.ExtractDictionary(jsonDictionary, jsonDictionary.ContainsKey("response") ? "response:venue" : "venue"); Id = Helpers.GetDictionaryValue(jsonDictionary, "id"); Name = Helpers.GetDictionaryValue(jsonDictionary, "name"); Verified = Helpers.GetDictionaryValue(jsonDictionary, "verified").Equals("True"); if (jsonDictionary.ContainsKey("contact")) Contact = new Contact((Dictionary<string, object>) jsonDictionary["contact"]); if (jsonDictionary.ContainsKey("location")) Location = new Location((Dictionary<string, object>) jsonDictionary["location"]); if (jsonDictionary.ContainsKey("categories")) foreach (var obj in ((object[]) jsonDictionary["categories"])) Categories.Add(new Category((Dictionary<string, object>) obj)); if (jsonDictionary.ContainsKey("specials")) foreach (var obj in (object[]) jsonDictionary["specials"]) Specials.Add(new Special((Dictionary<string, object>) obj)); if (jsonDictionary.ContainsKey("hereNow")) { if (((int)Helpers.ExtractDictionary(jsonDictionary, "hereNow")["count"]) > 0) { //TODO here now //throw new Exception("hereNow"); } } Description = Helpers.GetDictionaryValue(jsonDictionary, "description"); if (jsonDictionary.ContainsKey("stats")) Stats = new Stats((Dictionary<string, object>) jsonDictionary["stats"]); if (jsonDictionary.ContainsKey("mayor")) { Mayor = new Mayorship(Helpers.ExtractDictionary(jsonDictionary, "mayor")); // mayor.Checkins = Helpers.ExtractDictionary(jsonDictionary, "mayor")["count"].ToString(); } if (jsonDictionary.ContainsKey("tips")) { foreach (var obj in (object[])Helpers.ExtractDictionary(jsonDictionary, "tips")["groups"]) { var group = ((Dictionary<string, object>)obj); var tipList = (from tip in (object[]) ((Dictionary<string, object>) obj)["items"] select new Tip((Dictionary<string, object>) tip)).ToList(); Tips.Add(Helpers.GetDictionaryValue(group,"type"),tipList); } } if (jsonDictionary.ContainsKey("todos")) { //TODO: Todos //CRUEL IRONY if ((int)((Dictionary<string, Object>)jsonDictionary["todos"])["count"] > 0) { //throw new Exception("todos"); } } if (jsonDictionary.ContainsKey("tags")) foreach (var obj in (object[]) jsonDictionary["tags"]) Tags.Add((string) obj); if (jsonDictionary.ContainsKey("beenHere")) Int32.TryParse(((Dictionary<string, Object>) jsonDictionary["beenHere"])["count"].ToString(), out _beenHere); ShortUrl = Helpers.GetDictionaryValue(jsonDictionary, "shortUrl"); Url = Helpers.GetDictionaryValue(jsonDictionary, "url"); TimeZone = Helpers.GetDictionaryValue(jsonDictionary, "timeZone"); if (jsonDictionary.ContainsKey("specialsNearby")) foreach (var obj in (object[]) jsonDictionary["specialsNearby"]) { SpecialsNearby.Add(new Special((Dictionary<string, object>) obj)); throw new Exception("See if this actually worlks"); } if (jsonDictionary.ContainsKey("photos")) if ((int) ((Dictionary<string, object>) jsonDictionary["photos"])["count"] > 0) { //throw new Exception("To Do Item for this class"); //Todo } }
public User(Dictionary<string, object> jsonDictionary) : base(jsonDictionary) { Requests = "0"; Followers = "0"; Todos = "0"; Friends = "0"; Tips = "0"; MayorshipItems = new List<Venue>(); Mayorships = "0"; Badges = "0"; jsonDictionary = Helpers.ExtractDictionary(jsonDictionary, "response:user"); Id = Helpers.GetDictionaryValue(jsonDictionary, "id"); FirstName = Helpers.GetDictionaryValue(jsonDictionary, "firstName"); LastName = Helpers.GetDictionaryValue(jsonDictionary, "lastName"); HomeCity = Helpers.GetDictionaryValue(jsonDictionary, "homeCity"); Photo = Helpers.GetDictionaryValue(jsonDictionary, "photo"); Gender = Helpers.GetDictionaryValue(jsonDictionary, "gender"); Relationship = Helpers.GetDictionaryValue(jsonDictionary, "relationship"); Photo = Helpers.GetDictionaryValue(jsonDictionary, "photo"); Gender = Helpers.GetDictionaryValue(jsonDictionary, "gender"); Relationship = Helpers.GetDictionaryValue(jsonDictionary, "relationship"); if (jsonDictionary.ContainsKey("badges")) Badges = Helpers.ExtractDictionary(jsonDictionary, "badges")["count"].ToString(); if (jsonDictionary.ContainsKey("mayorships")) { Mayorships = Helpers.ExtractDictionary(jsonDictionary, "mayorships")["count"].ToString(); foreach (var obj in (Object[]) Helpers.ExtractDictionary(jsonDictionary, "mayorships")["items"]) MayorshipItems.Add(new Venue((Dictionary<string, object>) obj)); } if (jsonDictionary.ContainsKey("checkins")) Checkins = new Checkins(Helpers.ExtractDictionary(jsonDictionary, "checkins")); if (jsonDictionary.ContainsKey("friends")) { Friends = Helpers.ExtractDictionary(jsonDictionary, "friends")["count"].ToString(); //Todo: if the count >0, get the items } if (jsonDictionary.ContainsKey("followers")) { Followers = Helpers.ExtractDictionary(jsonDictionary, "followers")["count"].ToString(); //Todo: if the count >0, get the items } if (jsonDictionary.ContainsKey("requests")) { Requests = Helpers.ExtractDictionary(jsonDictionary, "requests")["count"].ToString(); //Todo: if the count >0, get the items } if (jsonDictionary.ContainsKey("tips")) { Tips = Helpers.ExtractDictionary(jsonDictionary, "tips")["count"].ToString(); //Todo: if the count >0, get the items } if (jsonDictionary.ContainsKey("todos")) { Todos = Helpers.ExtractDictionary(jsonDictionary, "todos")["count"].ToString(); //Todo: if the count >0, get the items } Type = Helpers.GetDictionaryValue(jsonDictionary, "type"); if (jsonDictionary.ContainsKey("contact")) Contact = new Contact(Helpers.ExtractDictionary(jsonDictionary, "contact")); Pings = Helpers.GetDictionaryValue(jsonDictionary, "pings"); if (jsonDictionary.ContainsKey("scores")) Scores = new Score(Helpers.ExtractDictionary(jsonDictionary, "scores")); }