Exemple #1
0
        public static VKCounters Deserialize(object Countries)
        {
            var counrties_des=new VKCounters();
            var data=(Dictionary<string,object>)Countries;

            object albums,videos,audios,notes,groups,photos,friends,online_friends,mutual_friends,
                   user_videos,user_photos,followers,subscriptions,topics,docs,pages;

            if(data.TryGetValue("albums",out albums))
                counrties_des.albums=(int)(long)albums;
            if(data.TryGetValue("videos",out videos))
                counrties_des.videos=(int)(long)videos;
            if(data.TryGetValue("audios",out audios))
                counrties_des.audios=(int)(long)audios;
            if(data.TryGetValue("notes",out notes))
                counrties_des.notes=(int)(long)notes;
            if(data.TryGetValue("groups",out groups))
                counrties_des.groups=(int)(long)groups;
            if(data.TryGetValue("photos",out photos))
                counrties_des.photos=(int)(long)photos;
            if(data.TryGetValue("friends",out friends))
                counrties_des.friends=(int)(long)friends;
            if(data.TryGetValue("online_friends",out online_friends))
                counrties_des.online_friends=(int)(long)online_friends;
            if(data.TryGetValue("mutual_friends",out mutual_friends))
                counrties_des.mutual_friends=(int)(long)mutual_friends;
            if(data.TryGetValue("user_videos",out user_videos))
                counrties_des.user_videos=(int)(long)user_videos;
            if(data.TryGetValue("user_photos",out user_photos))
                counrties_des.user_photos=(int)(long)user_photos;
            if(data.TryGetValue("followers",out followers))
                counrties_des.followers=(int)(long)followers;
            if(data.TryGetValue("subscriptions",out subscriptions))
                counrties_des.subscriptions=(int)(long) subscriptions;
            if(data.TryGetValue("topics",out topics))
                counrties_des.topics=(int)(long)topics;
            if(data.TryGetValue("docs",out docs))
                counrties_des.docs=(int)(long)docs;
            if(data.TryGetValue("pages",out pages))
                counrties_des.pages=(int)(long)pages;

            return counrties_des;
        }
        public static VKUser Deserialize(object User)
        {
            var userDeserialized = new VKUser();
            var usr = (Dictionary <string, object>)User;

            object id, firstName, last_name, hidden, deactivated, verified, blacklisted, sex, bdate, city, country, home_town;
            object photo_50, photo_100, photo_200_orig, photo_200, photo_400_orig, photo_max, photo_max_orig;
            object online, lists, domain, has_mobile, mobile_phone, home_phone, site;

            if (usr.TryGetValue("id", out id))
            {
                userDeserialized.id = (long)id;
            }

            if (usr.TryGetValue("first_name", out firstName))
            {
                userDeserialized.first_name = (string)firstName;
            }

            if (usr.TryGetValue("last_name", out last_name))
            {
                userDeserialized.last_name = (string)last_name;
            }

            if (usr.TryGetValue("deactivated", out deactivated))
            {
                userDeserialized.deactivated = (string)deactivated;
            }

            if (usr.TryGetValue("hidden", out hidden))
            {
                userDeserialized.hidden = (int)(long)hidden;
            }

            if (usr.TryGetValue("verified", out verified))
            {
                userDeserialized.verified = (int)(long)verified;
            }

            if (usr.TryGetValue("blacklisted", out blacklisted))
            {
                userDeserialized.blacklisted = (int)(long)blacklisted;
            }

            if (usr.TryGetValue("sex", out sex))
            {
                userDeserialized.sex = (int)(long)sex;
            }

            if (usr.TryGetValue("bdate", out bdate))
            {
                userDeserialized.bdate = (string)bdate;
            }

            if (usr.TryGetValue("city", out city))
            {
                userDeserialized.city = (string)city;
            }

            if (usr.TryGetValue("country", out country))
            {
                userDeserialized.country = (string)country;
            }

            if (usr.TryGetValue("home_town", out home_town))
            {
                userDeserialized.home_town = (string)home_town;
            }

            if (usr.TryGetValue("home_phone", out home_phone))
            {
                userDeserialized.home_phone = (string)home_phone;
            }

            if (usr.TryGetValue("photo_50", out photo_50))
            {
                userDeserialized.photo_50 = (string)photo_50;
            }

            if (usr.TryGetValue("photo_100", out photo_100))
            {
                userDeserialized.photo_100 = (string)photo_100;
            }

            if (usr.TryGetValue("photo_200", out photo_200))
            {
                userDeserialized.photo_200 = (string)photo_200;
            }

            if (usr.TryGetValue("photo_200_orig", out photo_200_orig))
            {
                userDeserialized.photo_200_orig = (string)photo_200_orig;
            }

            if (usr.TryGetValue("photo_400_orig", out photo_400_orig))
            {
                userDeserialized.photo_400_orig = (string)photo_400_orig;
            }

            if (usr.TryGetValue("photo_max", out photo_max))
            {
                userDeserialized.photo_max = (string)photo_max;
            }

            if (usr.TryGetValue("photo_max_orig", out photo_max_orig))
            {
                userDeserialized.photo_max_orig = (string)photo_max_orig;
            }

            if (usr.TryGetValue("online", out online))
            {
                userDeserialized.online = int.Parse(online.ToString());
            }

            if (usr.TryGetValue("lists", out lists))
            {
                userDeserialized.lists = new List <long>();
                foreach (var i in (List <object>)lists)
                {
                    userDeserialized.lists.Add((long)i);
                }
            }

            if (usr.TryGetValue("domain", out domain))
            {
                userDeserialized.domain = (string)domain;
            }

            if (usr.TryGetValue("has_mobile", out has_mobile))
            {
                userDeserialized.has_mobile = (int)(long)has_mobile;
            }

            if (usr.TryGetValue("mobile_phone", out mobile_phone))
            {
                userDeserialized.mobile_phone = (string)mobile_phone;
            }

            if (usr.TryGetValue("home_phone", out home_phone))
            {
                userDeserialized.home_phone = (string)home_phone;
            }

            if (usr.TryGetValue("site", out site))
            {
                userDeserialized.site = (string)site;
            }

            object university, university_name, faculty, faculty_name, graduation;

            if (usr.TryGetValue("university", out university))
            {
                userDeserialized.university = (long)university;
            }

            if (usr.TryGetValue("university_name", out university_name))
            {
                userDeserialized.university_name = (string)university_name;
            }

            if (usr.TryGetValue("faculty", out faculty))
            {
                userDeserialized.faculty = (long)faculty;
            }

            if (usr.TryGetValue("faculty_name", out faculty_name))
            {
                userDeserialized.faculty_name = (string)faculty_name;
            }

            if (usr.TryGetValue("graduation", out graduation))
            {
                userDeserialized.graduation = (int)(long)graduation;
            }

            object universities, schools, status, status_audio, followers_count, common_count, counters, occupation;

            if (usr.TryGetValue("universities", out universities))
            {
                var _universities = new List <VKUniversity>();
                var unidata       = (List <object>)universities;
                foreach (var u in unidata)
                {
                    _universities.Add(VKUniversity.Deserialize(u));
                }

                userDeserialized.universities = _universities;
            }

            if (usr.TryGetValue("schools", out schools))
            {
                var _schools = new List <VKSchool>();
                var unidata  = (List <object>)schools;
                foreach (var s in unidata)
                {
                    _schools.Add(VKSchool.Deserialize(s));
                }

                userDeserialized.schools = _schools;
            }

            if (usr.TryGetValue("status", out status))
            {
                userDeserialized.status = (string)status;
            }

            if (usr.TryGetValue("status_audio", out status_audio))
            {
                userDeserialized.status_audio = VKAudio.Deserialize(status_audio);
            }

            if (usr.TryGetValue("followers_count", out followers_count))
            {
                userDeserialized.followers_count = (int)(long)followers_count;
            }

            if (usr.TryGetValue("common_count", out common_count))
            {
                userDeserialized.common_count = (int)(long)common_count;
            }


            if (usr.TryGetValue("counters", out counters))
            {
                userDeserialized.counters = VKCounters.Deserialize(counters);
            }

            if (usr.TryGetValue("occupation", out occupation))
            {
                userDeserialized.occupation = VKUserOccupation.Deserialize(occupation);
            }

            object nickname, relatives, relation, personal, facebook, twitter, livejournal, instagram, exports, wall_comments;

            if (usr.TryGetValue("nickname", out nickname))
            {
                userDeserialized.nickname = (string)nickname;
            }

            if (usr.TryGetValue("relatives", out relatives))
            {
                var rel        = (List <object>)relatives;
                var _relatives = new List <VKUserRelative>();
                foreach (var r in rel)
                {
                    _relatives.Add(VKUserRelative.Deserialize(r));
                }
                userDeserialized.relatives = _relatives;
            }

            if (usr.TryGetValue("relation", out relation))
            {
                userDeserialized.relation = (int)(long)relation;
            }

            if (usr.TryGetValue("personal", out personal))
            {
                userDeserialized.personal = VKUserPersonal.Deserialize(personal);
            }

            if (usr.TryGetValue("facebook", out facebook))
            {
                userDeserialized.facebook = (string)facebook;
            }

            if (usr.TryGetValue("twitter", out twitter))
            {
                userDeserialized.twitter = (string)twitter;
            }

            if (usr.TryGetValue("livejournal", out livejournal))
            {
                userDeserialized.livejournal = (string)livejournal;
            }

            if (usr.TryGetValue("instagram", out instagram))
            {
                userDeserialized.instagram = (string)instagram;
            }

            if (usr.TryGetValue("exports", out exports))
            {
                userDeserialized.exports = VKUserExports.Deserialize(exports);
            }

            if (usr.TryGetValue("wall_comments", out wall_comments))
            {
                userDeserialized.wall_comments = (int)(long)wall_comments;
            }

            object activities, interests, movies, tv, books, games, about,
                   quotes, can_post, can_see_all_posts, can_see_audio, can_write_private_message,
                   timezone, screen_name, maiden_name;

            if (usr.TryGetValue("activities", out activities))
            {
                userDeserialized.activities = (string)activities;
            }


            if (usr.TryGetValue("interests", out interests))
            {
                userDeserialized.interests = (string)interests;
            }

            if (usr.TryGetValue("movies", out movies))
            {
                userDeserialized.movies = (string)movies;
            }

            if (usr.TryGetValue("tv", out tv))
            {
                userDeserialized.tv = (string)tv;
            }

            if (usr.TryGetValue("books", out books))
            {
                userDeserialized.books = (string)books;
            }

            if (usr.TryGetValue("games", out games))
            {
                userDeserialized.games = (string)games;
            }

            if (usr.TryGetValue("about", out about))
            {
                userDeserialized.about = (string)about;
            }

            if (usr.TryGetValue("quotes", out quotes))
            {
                userDeserialized.quotes = (string)quotes;
            }

            if (usr.TryGetValue("can_post", out can_post))
            {
                userDeserialized.can_post = (int)(long)can_post;
            }

            if (usr.TryGetValue("can_see_all_posts", out can_see_all_posts))
            {
                userDeserialized.can_see_all_posts = (int)(long)can_see_all_posts;
            }

            if (usr.TryGetValue("can_see_audio", out can_see_audio))
            {
                userDeserialized.can_see_audio = (int)(long)can_see_audio;
            }

            if (usr.TryGetValue("can_write_private_message", out can_write_private_message))
            {
                userDeserialized.can_write_private_message = (int)(long)can_write_private_message;
            }

            if (usr.TryGetValue("timezone", out timezone))
            {
                userDeserialized.timezone = (int)(long)timezone;
            }

            if (usr.TryGetValue("screen_name", out screen_name))
            {
                userDeserialized.screen_name = (string)screen_name;
            }

            if (usr.TryGetValue("maiden_name", out maiden_name))
            {
                userDeserialized.maiden_name = (string)maiden_name;
            }

            return(userDeserialized);
        }
        public static VKCounters Deserialize(object Countries)
        {
            var counrties_des = new VKCounters();
            var data          = (Dictionary <string, object>)Countries;

            object albums, videos, audios, notes, groups, photos, friends, online_friends, mutual_friends,
                   user_videos, user_photos, followers, subscriptions, topics, docs, pages;

            if (data.TryGetValue("albums", out albums))
            {
                counrties_des.albums = (int)(long)albums;
            }
            if (data.TryGetValue("videos", out videos))
            {
                counrties_des.videos = (int)(long)videos;
            }
            if (data.TryGetValue("audios", out audios))
            {
                counrties_des.audios = (int)(long)audios;
            }
            if (data.TryGetValue("notes", out notes))
            {
                counrties_des.notes = (int)(long)notes;
            }
            if (data.TryGetValue("groups", out groups))
            {
                counrties_des.groups = (int)(long)groups;
            }
            if (data.TryGetValue("photos", out photos))
            {
                counrties_des.photos = (int)(long)photos;
            }
            if (data.TryGetValue("friends", out friends))
            {
                counrties_des.friends = (int)(long)friends;
            }
            if (data.TryGetValue("online_friends", out online_friends))
            {
                counrties_des.online_friends = (int)(long)online_friends;
            }
            if (data.TryGetValue("mutual_friends", out mutual_friends))
            {
                counrties_des.mutual_friends = (int)(long)mutual_friends;
            }
            if (data.TryGetValue("user_videos", out user_videos))
            {
                counrties_des.user_videos = (int)(long)user_videos;
            }
            if (data.TryGetValue("user_photos", out user_photos))
            {
                counrties_des.user_photos = (int)(long)user_photos;
            }
            if (data.TryGetValue("followers", out followers))
            {
                counrties_des.followers = (int)(long)followers;
            }
            if (data.TryGetValue("subscriptions", out subscriptions))
            {
                counrties_des.subscriptions = (int)(long)subscriptions;
            }
            if (data.TryGetValue("topics", out topics))
            {
                counrties_des.topics = (int)(long)topics;
            }
            if (data.TryGetValue("docs", out docs))
            {
                counrties_des.docs = (int)(long)docs;
            }
            if (data.TryGetValue("pages", out pages))
            {
                counrties_des.pages = (int)(long)pages;
            }

            return(counrties_des);
        }
        public static VKGroup Deserialise(object group)
        {
            var    data = (Dictionary <string, object>)group;
            var    _group = new VKGroup();
            object id, name, screen_name, is_closed, deactivated, is_admin, admin_level, is_member;

            if (data.TryGetValue("id", out id))
            {
                _group.id = (long)id;
            }

            if (data.TryGetValue("name", out name))
            {
                _group.name = (string)name;
            }

            if (data.TryGetValue("screen_name", out screen_name))
            {
                _group.screen_name = (string)screen_name;
            }

            if (data.TryGetValue("is_closed", out is_closed))
            {
                _group.is_closed = (int)(long)is_closed;
            }

            if (data.TryGetValue("deactivated", out deactivated))
            {
                _group.deactivated = (string)deactivated;
            }

            if (data.TryGetValue("is_admin", out is_admin))
            {
                _group.is_admin = (int)(long)is_admin;
            }

            if (data.TryGetValue("admin_level", out admin_level))
            {
                _group.admin_level = (int)(long)admin_level;
            }

            if (data.TryGetValue("is_member", out is_member))
            {
                _group.is_member = (int)(long)is_member;
            }

            object type, photo_50, photo_100, photo_200, city, country, place, description, wiki_page;

            if (data.TryGetValue("type", out type))
            {
                _group.type = (string)type;
            }
            if (data.TryGetValue("photo_50", out photo_50))
            {
                _group.photo_50 = (string)photo_50;
            }
            if (data.TryGetValue("photo_100", out photo_100))
            {
                _group.photo_100 = (string)photo_100;
            }
            if (data.TryGetValue("photo_200", out photo_200))
            {
                _group.photo_200 = (string)photo_200;
            }
            if (data.TryGetValue("city", out city))
            {
                _group.city = (long)city;
            }
            if (data.TryGetValue("country", out country))
            {
                _group.country = (long)country;
            }
            if (data.TryGetValue("place", out place))
            {
                _group.place = VKPlace.Deserialize(place);
            }
            if (data.TryGetValue("description", out description))
            {
                _group.description = (string)description;
            }
            if (data.TryGetValue("wiki_page", out wiki_page))
            {
                _group.wiki_page = (string)wiki_page;
            }

            object members_count, counters, start_date, finish_date, can_post, can_see_all_posts, can_upload_doc, can_create_topic;

            if (data.TryGetValue("members_count", out members_count))
            {
                _group.members_count = (int)(long)members_count;
            }
            if (data.TryGetValue("counters", out counters))
            {
                _group.counters = VKCounters.Deserialize(counters);
            }
            if (data.TryGetValue("start_date", out start_date))
            {
                _group.start_date = (long)start_date;
            }
            if (data.TryGetValue("finish_date", out finish_date))
            {
                _group.finish_date = (long)finish_date;
            }
            if (data.TryGetValue("can_post", out can_post))
            {
                _group.can_post = (int)(long)can_post;
            }
            if (data.TryGetValue("can_see_all_posts", out can_see_all_posts))
            {
                _group.can_see_all_posts = (int)(long)can_see_all_posts;
            }
            if (data.TryGetValue("can_upload_doc", out can_upload_doc))
            {
                _group.can_upload_doc = (int)(long)can_upload_doc;
            }
            if (data.TryGetValue("can_create_topic", out can_create_topic))
            {
                _group.can_create_topic = (int)(long)can_create_topic;
            }

            object activity, status, contacts, links, fixed_post, verified, site;

            if (data.TryGetValue("activity", out activity))
            {
                _group.activity = (string)activity;
            }
            if (data.TryGetValue("status", out status))
            {
                _group.status = (string)status;
            }
            if (data.TryGetValue("contacts", out contacts))
            {
                _group.contacts = (string)contacts;
            }
            if (data.TryGetValue("links", out links))
            {
                _group.links = (string)links;
            }
            if (data.TryGetValue("fixed_post", out fixed_post))
            {
                _group.fixed_post = (long)fixed_post;
            }
            if (data.TryGetValue("verified", out verified))
            {
                _group.verified = (int)(long)verified;
            }
            if (data.TryGetValue("site", out site))
            {
                _group.site = (string)site;
            }
            return(_group);
        }