public FourSquareVenue(Dictionary<string, object> JSONDictionary) : base(JSONDictionary) { if (JSONDictionary.ContainsKey("response")) { JSONDictionary = ExtractDictionary(JSONDictionary, "response:venue"); } else { JSONDictionary = ExtractDictionary(JSONDictionary, "venue"); } id = GetDictionaryValue(JSONDictionary, "id"); name = GetDictionaryValue(JSONDictionary, "name"); verified = GetDictionaryValue(JSONDictionary, "verified").Equals("True"); if (JSONDictionary.ContainsKey("contact")) { contact = new FourSquareContact((Dictionary<string, object>)JSONDictionary["contact"]); } if (JSONDictionary.ContainsKey("location")) { location = new FourSquareLocation((Dictionary<string, object>)JSONDictionary["location"]); } if (JSONDictionary.ContainsKey("categories")) { foreach (object obj in (GetDictionaryList( JSONDictionary, "categories"))) { categories.Add(new FourSquareCategory((Dictionary<string, object>)obj)); } } if (JSONDictionary.ContainsKey("specials")) { foreach (object Obj in (GetDictionaryList( JSONDictionary,"specials"))) { specials.Add(new FourSquareSpecial((Dictionary<string, object>)Obj)); } } if (JSONDictionary.ContainsKey("hereNow")) { hereNow = new FourSquareHereNow(ExtractDictionary(JSONDictionary, "hereNow")); } description = GetDictionaryValue(JSONDictionary, "description"); if (JSONDictionary.ContainsKey("stats")) { stats = new FourSquareStats((Dictionary<string, object>)JSONDictionary["stats"]); } if (JSONDictionary.ContainsKey("mayor")) { mayor = new FourSquareMayorship(ExtractDictionary(JSONDictionary, "mayor")); mayor.Checkins = ExtractDictionary(JSONDictionary, "mayor")["count"].ToString(); } if (JSONDictionary.ContainsKey("tips")) { foreach (object Obj in (GetDictionaryList( ExtractDictionary(JSONDictionary, "tips"),"groups"))) { Dictionary<string, object> Group = ((Dictionary<string, object>)Obj); List<FourSquareTip> TipList = new List<FourSquareTip>(); foreach (object Tip in GetDictionaryList((Dictionary<string, object>)Obj,"items")) { TipList.Add(new FourSquareTip((Dictionary<string, object>)Tip)); } tips.Add(GetDictionaryValue(Group, "type"), TipList); } } if (JSONDictionary.ContainsKey("todos")) { //TODO: Todos //IRONY - NOt Working /* if (Convert.ToInt16(GetDictionaryValue(ExtractDictionary(JSONDictionary,"todos"),"count")) > 0) { foreach (object Obj in GetDictionaryList(ExtractDictionary(JSONDictionary, "todos"), "items")) { todos.Add(new FourSquareTodo((Dictionary<string,object>)Obj)); } }*/ } if (JSONDictionary.ContainsKey("tags")) { foreach (object Obj in (GetDictionaryList( JSONDictionary, "tags"))) { tags.Add((string)Obj); } } if (JSONDictionary.ContainsKey("beenHere")) { // Int32.TryParse(((Dictionary<string, Object>)JSONDictionary["beenHere"])["count"].ToString(), out beenHere); try { beenHere = Int32.Parse(((Dictionary<string, Object>)JSONDictionary["beenHere"])["count"].ToString()); } catch { beenHere = 0; } } shortUrl = GetDictionaryValue(JSONDictionary, "shortUrl"); url = GetDictionaryValue(JSONDictionary, "url"); timeZone = GetDictionaryValue(JSONDictionary, "timeZone"); if (JSONDictionary.ContainsKey("specialsNearby")) { foreach (object Obj in (GetDictionaryList( JSONDictionary, "specialsNearby"))) { specialsNearby.Add(new FourSquareSpecial((Dictionary<string, object>)Obj)); throw new Exception("See if this actually worlks"); } } if (JSONDictionary.ContainsKey("photos")) { if (ExtractDictionary(JSONDictionary,"photos").Count > 0) { Dictionary<string, object> PhotoDictionary = ExtractDictionary(JSONDictionary, "photos"); foreach (object Obj in GetDictionaryList(PhotoDictionary, "groups")) { photos.Add(new FourSquarePhotoGroup((Dictionary<string,object>)Obj)); } } } }
public FourSquareVenue(Dictionary<string, object> JSONDictionary) { JSON = JSONSerializer(JSONDictionary); id = GetDictionaryValue(JSONDictionary, "id"); name = GetDictionaryValue(JSONDictionary, "name"); verified = GetDictionaryValue(JSONDictionary, "verified").Equals("True"); contact = new FourSquareContact((Dictionary<string, object>)JSONDictionary["contact"]); if (JSONDictionary.ContainsKey("location")) { location = new FourSquareLocation((Dictionary<string, object>)JSONDictionary["location"]); } if (JSONDictionary.ContainsKey("categories")) { foreach (object obj in ((object[])JSONDictionary["categories"])) { categories.Add(new FourSquareCategory((Dictionary<string, object>)obj)); } } if (JSONDictionary.ContainsKey("specials")) { foreach (object Obj in (object[])JSONDictionary["specials"]) { specials.Add(new FourSquareSpecial((Dictionary<string, object>)Obj)); } } if (JSONDictionary.ContainsKey("hereNow")) { if (((int)ExtractDictionary(JSONDictionary, "hereNow")["count"]) > 0) { //TODO here now //throw new Exception("hereNow"); } } description = GetDictionaryValue(JSONDictionary, "description"); if (JSONDictionary.ContainsKey("stats")) { stats = new FourSquareStats((Dictionary<string, object>)JSONDictionary["stats"]); } if (JSONDictionary.ContainsKey("mayor")) { mayor = new FourSquareMayorship(ExtractDictionary(JSONDictionary, "mayor")); mayor.Checkins = ExtractDictionary(JSONDictionary, "mayor")["count"].ToString(); } if (JSONDictionary.ContainsKey("tips")) { foreach (object Obj in (object[])ExtractDictionary(JSONDictionary, "tips")["groups"]) { Dictionary<string, object> Group = ((Dictionary<string, object>)Obj); List<FourSquareTip> TipList = new List<FourSquareTip>(); foreach (object Tip in (object[])((Dictionary<string, object>)Obj)["items"]) { TipList.Add(new FourSquareTip((Dictionary<string, object>)Tip)); } tips.Add(GetDictionaryValue(Group, "type"), TipList); } } if (JSONDictionary.ContainsKey("todos")) { //TODO: Todos //IRONY if ((int)((Dictionary<string, Object>)JSONDictionary["todos"])["count"] > 0) { //throw new Exception("todos"); } } if (JSONDictionary.ContainsKey("tags")) { foreach (object Obj in (object[])JSONDictionary["tags"]) { tags.Add((string)Obj); } } Int32.TryParse(GetDictionaryValue(JSONDictionary, "beenHere"), out beenHere); shortUrl = GetDictionaryValue(JSONDictionary, "shortUrl"); url = GetDictionaryValue(JSONDictionary, "url"); timeZone = GetDictionaryValue(JSONDictionary, "timeZone"); if (JSONDictionary.ContainsKey("specialsNearby")) { foreach (object Obj in (object[])JSONDictionary["specialsNearby"]) { specialsNearby.Add(new FourSquareSpecial((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"); // } //} }
public FourSquareCheckin(Dictionary<string, object> JSONDictionary) : base(JSONDictionary) { JSONDictionary = ExtractDictionary(JSONDictionary, "response:checkin"); id = GetDictionaryValue(JSONDictionary, "id"); type = GetDictionaryValue(JSONDictionary, "type"); _private = GetDictionaryValue(JSONDictionary, "private"); if (JSONDictionary.ContainsKey("user")) { user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); } timeZone = GetDictionaryValue(JSONDictionary, "timeZone"); if (JSONDictionary.ContainsKey("venue")) { venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]); } if (JSONDictionary.ContainsKey("location")) { location = new FourSquareLocation((Dictionary<string, object>)JSONDictionary["location"]); } shout = GetDictionaryValue(JSONDictionary, "shout"); createdAt = GetDictionaryValue(JSONDictionary, "createdAt"); if (JSONDictionary.ContainsKey("source")) { source = new FourSquareSource((Dictionary<string, object>)JSONDictionary["source"]); } if (JSONDictionary.ContainsKey("photos")) { Dictionary<string, object> PhotoThings = (Dictionary<string, object>)JSONDictionary["photos"]; if (Int32.Parse(PhotoThings["count"].ToString()) > 0) { foreach (object PhotoObj in (GetDictionaryList( PhotoThings, "items"))) { photos.Add(new FourSquarePhoto((Dictionary<string, object>)PhotoObj)); } } } if (JSONDictionary.ContainsKey("comments")) { if ((GetDictionaryList( ExtractDictionary(JSONDictionary, "comments"),"items")).Count > 0) { foreach (object obj in (GetDictionaryList( ExtractDictionary(JSONDictionary, "comments"),"items"))) { comments.Add(new FourSquareComment((Dictionary<string, object>)obj)); } } } if (JSONDictionary.ContainsKey("overlaps")) { foreach (object obj in (GetDictionaryList(ExtractDictionary(JSONDictionary, "overlaps"),"items"))) { overlaps.Add(new FourSquareOverlaps((Dictionary<string, object>)obj)); } } if (JSONDictionary.ContainsKey("isMayor")) { if (JSONDictionary["isMayor"].ToString().Equals("True")) { IsMayor = true; } } }
public FourSquareCheckin(Dictionary<string, object> JSONDictionary) { JSON = JSONSerializer(JSONDictionary); id = GetDictionaryValue(JSONDictionary, "id"); type = GetDictionaryValue(JSONDictionary, "type"); _private = GetDictionaryValue(JSONDictionary, "private"); if (JSONDictionary.ContainsKey("user")) { user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); } timeZone = GetDictionaryValue(JSONDictionary, "timeZone"); if (JSONDictionary.ContainsKey("venue")) { venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]); } if (JSONDictionary.ContainsKey("location")) { location = new FourSquareLocation((Dictionary<string, object>)JSONDictionary["location"]); } shout = GetDictionaryValue(JSONDictionary, "shout"); createdAt = GetDictionaryValue(JSONDictionary, "createdAt"); if (JSONDictionary.ContainsKey("source")) { source = new FourSquareSource((Dictionary<string, object>)JSONDictionary["source"]); } if (JSONDictionary.ContainsKey("photos")) { Dictionary<string, object> PhotoThings = (Dictionary<string, object>)JSONDictionary["photos"]; if (Int32.Parse(PhotoThings["count"].ToString()) > 0) { foreach (object obj in (object[])PhotoThings["items"]) { //TODO: Photos as an object throw new Exception("Photos here!"); } } } if (JSONDictionary.ContainsKey("comments")) { if (((object[])ExtractDictionary(JSONDictionary, "comments")["items"]).Length > 0) { foreach (object obj in ((object[])ExtractDictionary(JSONDictionary, "comments")["items"])) { comments.Add(new FourSquareComment((Dictionary<string, object>)obj)); } } } if (JSONDictionary.ContainsKey("overlaps")) { foreach (object obj in ((object[])ExtractDictionary(JSONDictionary, "overlaps")["items"])) { overlaps.Add(new FourSquareOverlaps((Dictionary<string, object>)obj)); } } if (JSONDictionary.ContainsKey("isMayor")) { if (JSONDictionary["isMayor"].ToString().Equals("True")) { IsMayor = true; } } }