Ejemplo n.º 1
0
            public FourSquareUser(Dictionary<string, object> JSONDictionary)
                : base(JSONDictionary)
            {
                JSONDictionary = ExtractDictionary(JSONDictionary, "response:user");

                id = GetDictionaryValue(JSONDictionary, "id");

                firstName = GetDictionaryValue(JSONDictionary, "firstName");
                lastName = GetDictionaryValue(JSONDictionary, "lastName");
                homeCity = GetDictionaryValue(JSONDictionary, "homeCity");

                photo = GetDictionaryValue(JSONDictionary, "photo");
                gender = GetDictionaryValue(JSONDictionary, "gender");
                relationship = GetDictionaryValue(JSONDictionary, "relationship");

                photo = GetDictionaryValue(JSONDictionary, "photo");
                gender = GetDictionaryValue(JSONDictionary, "gender");
                relationship = GetDictionaryValue(JSONDictionary, "relationship");

                if (JSONDictionary.ContainsKey("badges"))
                {
                    badges = ExtractDictionary(JSONDictionary, "badges")["count"].ToString();
                }
                if (JSONDictionary.ContainsKey("mayorships"))
                {
                    mayorships = ExtractDictionary(JSONDictionary, "mayorships")["count"].ToString();
                    List<object> MayorList = GetDictionaryList(JSONDictionary, "items");
                    foreach (object Obj in MayorList)
                    {
                        mayorshipItems.Add(new FourSquareVenue((Dictionary<string, object>)Obj));
                    }
                }
                if (JSONDictionary.ContainsKey("checkins"))
                {
                    checkins = ExtractDictionary(JSONDictionary, "checkins")["count"].ToString();
                    //Todo: if the count >0, get the items
                }
                if (JSONDictionary.ContainsKey("friends"))
                {
                    friends = ExtractDictionary(JSONDictionary, "friends")["count"].ToString();
                    //Todo: if the count >0, get the items
                }
                if (JSONDictionary.ContainsKey("followers"))
                {
                    followers = ExtractDictionary(JSONDictionary, "followers")["count"].ToString();
                    //Todo: if the count >0, get the items
                }
                if (JSONDictionary.ContainsKey("requests"))
                {
                    requests = ExtractDictionary(JSONDictionary, "requests")["count"].ToString();
                    //Todo: if the count >0, get the items
                }
                if (JSONDictionary.ContainsKey("tips"))
                {
                    tips = ExtractDictionary(JSONDictionary, "tips")["count"].ToString();
                    //Todo: if the count >0, get the items
                }
                if (JSONDictionary.ContainsKey("todos"))
                {
                    todos = ExtractDictionary(JSONDictionary, "todos")["count"].ToString();
                    //Todo: if the count >0, get the items
                }

                type = GetDictionaryValue(JSONDictionary, "type");
                if (JSONDictionary.ContainsKey("contact"))
                {
                    contact = new FourSquareContact((Dictionary<string, object>)JSONDictionary["contact"]);
                }
                pings = GetDictionaryValue(JSONDictionary, "pings");
            }
Ejemplo n.º 2
0
            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));
                        }
                    }
                }
            }
Ejemplo n.º 3
0
        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");
            //    }
            //}
        }