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; }
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); }
public static VKComment Deserialize(object Comment) { var data = (Dictionary <string, object>)Comment; var _comment = new VKComment(); object id, from_id, date, text, reply_to_user, reply_to_comment, attachments; if (data.TryGetValue("id", out id)) { _comment.id = (long)id; } if (data.TryGetValue("from_id", out from_id)) { _comment.from_id = (long)from_id; } if (data.TryGetValue("date", out date)) { _comment.date = (long)date; } if (data.TryGetValue("text", out text)) { _comment.text = (string)text; } if (data.TryGetValue("reply_to_user", out reply_to_user)) { _comment.reply_to_user = (long)reply_to_user; } if (data.TryGetValue("reply_to_comment", out reply_to_comment)) { _comment.reply_to_comment = (long)reply_to_comment; } if (data.TryGetValue("attachments", out attachments)) { var att = (List <object>)attachments; var _attachments = new List <VKAttachment>(); foreach (var a in att) { _attachments.Add(VKAttachment.Deserialize(a)); } _comment.attachments = _attachments; } return(_comment); }
public static VKMessage Deserialize(object message) { var data = (Dictionary <string, object>)message; var _message = new VKMessage(); object id, user_id, date, read_state, @out, title, body, attachments, geo, fwd_messages, emoji, important, deleted, chat_id, chat_active, users_count, admin_id; if (data.TryGetValue("id", out id)) { _message.id = (long)id; } if (data.TryGetValue("user_id", out user_id)) { _message.user_id = (long)user_id; } if (data.TryGetValue("date", out date)) { _message.date = (long)date; } if (data.TryGetValue("read_state", out read_state)) { _message.read_state = (int)(long)read_state; } if (data.TryGetValue("out", out @out)) { _message.@out = (int)(long)@out; } if (data.TryGetValue("title", out title)) { _message.title = (string)title; } if (data.TryGetValue("body", out body)) { _message.body = (string)body; } if (data.TryGetValue("attachments", out attachments)) { var _attachments = new List <VKAttachment>(); var att = (List <object>)attachments; foreach (var a in att) { _attachments.Add(VKAttachment.Deserialize(a)); } _message.attachments = _attachments; } if (data.TryGetValue("geo", out geo)) { _message.geo = VKGeo.Deserialize(geo); } if (data.TryGetValue("fwd_messages", out fwd_messages)) { var _msg = new List <VKMessage>(); var data1 = (List <VKMessage>)fwd_messages; foreach (var d in data1) { _msg.Add(VKMessage.Deserialize(d)); } _message.fwd_messages = _msg; } if (data.TryGetValue("emoji", out emoji)) { _message.emoji = (int)(long)emoji; } if (data.TryGetValue("important", out important)) { _message.important = (int)(long)important; } if (data.TryGetValue("deleted", out deleted)) { _message.deleted = (int)(long)deleted; } if (data.TryGetValue("chat_id", out chat_id)) { _message.chat_id = (long)chat_id; } if (data.TryGetValue("chat_active", out chat_active)) { _message.chat_active = new List <long>(); foreach (var i in (List <object>)chat_active) { _message.chat_active.Add((long)i); } } if (data.TryGetValue("users_count", out users_count)) { _message.users_count = (int)(long)users_count; } if (data.TryGetValue("admin_id", out admin_id)) { _message.admin_id = (long)admin_id; } object push_settings, action, action_mid, action_email, action_text, photo_50, photo_100, photo_200; if (data.TryGetValue("push_settings", out push_settings)) { _message.push_settings = VKPushSettings.Deserialize(push_settings); } if (data.TryGetValue("action", out action)) { _message.action = (string)action; } if (data.TryGetValue("action_mid", out action_mid)) { _message.action_mid = (long)action_mid; } if (data.TryGetValue("action_email", out action_email)) { _message.action_email = (string)action_email; } if (data.TryGetValue("action_text", out action_text)) { _message.action_text = (string)action_text; } if (data.TryGetValue("photo_50", out photo_50)) { _message.photo_50 = (string)photo_50; } if (data.TryGetValue("photo_100", out photo_100)) { _message.photo_100 = (string)photo_100; } if (data.TryGetValue("photo_200", out photo_200)) { _message.photo_200 = (string)photo_200; } return(_message); }
public static VKWallPost Deserialize(object WallPost) { var _post = new VKWallPost(); var data = (Dictionary <string, object>)WallPost; object id, owner_id, from_id, date, text, reply_owner_id, reply_post_id, friends_only; if (data.TryGetValue("id", out id)) { _post.id = (long)id; } if (data.TryGetValue("owner_id", out owner_id)) { _post.owner_id = (long)owner_id; } if (data.TryGetValue("from_id", out from_id)) { _post.from_id = (long)from_id; } if (data.TryGetValue("date", out date)) { _post.date = (long)date; } if (data.TryGetValue("text", out text)) { _post.text = (string)text; } if (data.TryGetValue("reply_owner_id", out reply_owner_id)) { _post.reply_owner_id = (long)reply_owner_id; } if (data.TryGetValue("reply_post_id", out reply_post_id)) { _post.reply_post_id = (long)reply_post_id; } if (data.TryGetValue("friends_only", out friends_only)) { _post.friends_only = (int)(long)friends_only; } object comments, likes, reposts, post_type, post_source, attachments, geo; if (data.TryGetValue("comments", out comments)) { _post.comments = VKComments.Deserialize(comments); } if (data.TryGetValue("likes", out likes)) { _post.likes = VKLikes.Deserialize(likes); } if (data.TryGetValue("reposts", out reposts)) { _post.reposts = VKReposts.Deserialize(reposts); } if (data.TryGetValue("post_type", out post_type)) { _post.post_type = (string)post_type; } if (data.TryGetValue("post_source", out post_source)) { _post.post_source = VKPostSource.Deserialize(post_source); } if (data.TryGetValue("attachments", out attachments)) { var _att = new List <VKAttachment>(); foreach (var a in (List <object>)attachments) { _att.Add(VKAttachment.Deserialize(a)); } _post.attachments = _att; } if (data.TryGetValue("geo", out geo)) { _post.geo = VKGeo.Deserialize(geo); } object signer_id, copy_history, can_pin, is_pinned; if (data.TryGetValue("signer_id", out signer_id)) { _post.signer_id = (long)signer_id; } if (data.TryGetValue("copy_history", out copy_history)) { var h = new List <VKWallPost>(); foreach (var h1 in (List <object>)copy_history) { h.Add(VKWallPost.Deserialize(h1)); } _post.copy_history = h; } if (data.TryGetValue("can_pin", out can_pin)) { _post.can_pin = (int)(long)can_pin; } if (data.TryGetValue("is_pinned", out is_pinned)) { _post.is_pinned = (int)(long)is_pinned; } return(_post); }