Exemple #1
0
        public static VKPoll Deserialize(object poll)
        {
            var data = (Dictionary<string,object>)poll;
            var _poll = new VKPoll ();

            object id, owner_id, created, is_closed, question, votes, answer_id, answers;
            if (data.TryGetValue ("id", out id))
                _poll.id = (long)id;
            if (data.TryGetValue ("owner_id", out owner_id))
                _poll.owner_id = (long)owner_id;
            if (data.TryGetValue ("created", out created))
                _poll.created = (long)created;
            if (data.TryGetValue ("is_closed", out is_closed))
                _poll.is_closed = (int)(long)is_closed;
            if (data.TryGetValue ("question", out question))
                _poll.question = (string)question;
            if (data.TryGetValue ("votes", out votes))
                _poll.votes = (int)(long)votes;
            if (data.TryGetValue ("answer_id", out answer_id))
                _poll.answer_id = (long)answer_id;

            if (data.TryGetValue ("answers", out answers)) {
                var _answers=new List<VKPollAnswer>();
                var ans=(List<object>)answers;
                foreach(var a in ans)
                {
                    _answers.Add(VKPollAnswer.Dererialize(a));
                }
                _poll.answers=_answers;
            }

            return _poll;
        }
Exemple #2
0
        public static VKPoll Deserialize(object poll)
        {
            var data  = (Dictionary <string, object>)poll;
            var _poll = new VKPoll();

            object id, owner_id, created, is_closed, question, votes, answer_id, answers;

            if (data.TryGetValue("id", out id))
            {
                _poll.id = (long)id;
            }
            if (data.TryGetValue("owner_id", out owner_id))
            {
                _poll.owner_id = (long)owner_id;
            }
            if (data.TryGetValue("created", out created))
            {
                _poll.created = (long)created;
            }
            if (data.TryGetValue("is_closed", out is_closed))
            {
                _poll.is_closed = (int)(long)is_closed;
            }
            if (data.TryGetValue("question", out question))
            {
                _poll.question = (string)question;
            }
            if (data.TryGetValue("votes", out votes))
            {
                _poll.votes = (int)(long)votes;
            }
            if (data.TryGetValue("answer_id", out answer_id))
            {
                _poll.answer_id = (long)answer_id;
            }

            if (data.TryGetValue("answers", out answers))
            {
                var _answers = new List <VKPollAnswer>();
                var ans      = (List <object>)answers;
                foreach (var a in ans)
                {
                    _answers.Add(VKPollAnswer.Dererialize(a));
                }
                _poll.answers = _answers;
            }


            return(_poll);
        }
        public static VKAttachment Deserialize(object attachment)
        {
            var    data = (Dictionary <string, object>)attachment;
            var    _atachment = new VKAttachment();
            object type, audio, photo, poll, doc, link, wall, note, Page;

            if (data.TryGetValue("type", out type))
            {
                _atachment.type = (string)type;
            }
            if (data.TryGetValue("audio", out audio))
            {
                _atachment.audio = VKAudio.Deserialize(audio);
            }
            if (data.TryGetValue("photo", out photo))
            {
                _atachment.photo = VKPhoto.Deserialize(photo);
            }
            if (data.TryGetValue("poll", out poll))
            {
                _atachment.poll = VKPoll.Deserialize(poll);
            }
            if (data.TryGetValue("doc", out doc))
            {
                _atachment.doc = VKDocument.Deserialize(doc);
            }
            if (data.TryGetValue("link", out link))
            {
                _atachment.link = VKLink.Deserialize(link);
            }
            if (data.TryGetValue("wall", out wall))
            {
                _atachment.wall = VKWallPost.Deserialize(wall);
            }
            if (data.TryGetValue("note", out note))
            {
                _atachment.note = VKNote.Deserialize(note);
            }
            if (data.TryGetValue("Page", out Page))
            {
                _atachment.Page = VKPage.Deserialize(Page);
            }
            return(_atachment);
        }