private void Parse(JObject jsonObject) { MessageId = jsonObject["message_id"].Value<int>(); From = new UserInfo(jsonObject["from"].Value<JObject>()); DateUnix = jsonObject["date"].Value<int>(); Date = DateUnix.ToDateTime(); Chat = ParseChat(jsonObject["chat"].Value<JObject>()); if (jsonObject["forward_from"] != null) ForwardFrom = new UserInfo(jsonObject["forward_from"].Value<JObject>()); if(jsonObject["forward_date"]!=null) { ForwardDateUnix = jsonObject["forward_date"].Value<int>(); ForwardDate = ForwardDateUnix.ToDateTime(); } if(jsonObject["reply_to_message"]!=null) { ReplyToMessage = new MessageInfo(jsonObject["reply_to_message"].Value<JObject>()); } if (jsonObject["text"] != null) Text = jsonObject["text"].Value<string>(); if (jsonObject["audio"] != null) Audio = new AudioInfo(jsonObject["audio"].Value<JObject>()); if (jsonObject["document"] != null) Document = new DocumentInfo(jsonObject["document"].Value<JObject>()); if (jsonObject["photo"] != null) Photo = PhotoSizeInfo.ParseArray(jsonObject["photo"].Value<JArray>()); if (jsonObject["sticker"] != null) Sticker = new StickerInfo(jsonObject["sticker"].Value<JObject>()); if (jsonObject["video"] != null) Video = new VideoInfo(jsonObject["video"].Value<JObject>()); if (jsonObject["contact"] != null) Contact = new ContactInfo(jsonObject["contact"].Value<JObject>()); if (jsonObject["location"] != null) Location = new LocationInfo(jsonObject["location"].Value<JObject>()); if (jsonObject["new_chat_participant"] != null) NewChatParticipant = new UserInfo(jsonObject["new_chat_participant"].Value<JObject>()); if (jsonObject["left_chat_participant"] != null) LeftChatParticipant = new UserInfo(jsonObject["left_chat_participant"].Value<JObject>()); if (jsonObject["new_chat_title"] != null) NewChatTitle = jsonObject["new_chat_title"].Value<string>(); if (jsonObject["new_chat_photo"] != null) NewChatPhoto = PhotoSizeInfo.ParseArray(jsonObject["new_chat_photo"].Value<JArray>()); if (jsonObject["delete_chat_photo"] != null) DeleteChatPhoto = true; if (jsonObject["group_chat_created"] != null) GroupChatCreated = true; }
private void Parse(JObject jsonObject) { MessageId = jsonObject["message_id"].Value <int>(); From = new UserInfo(jsonObject["from"].Value <JObject>()); DateUnix = jsonObject["date"].Value <int>(); Date = DateUnix.ToDateTime(); Chat = ParseChat(jsonObject["chat"].Value <JObject>()); if (jsonObject["forward_from"] != null) { ForwardFrom = new UserInfo(jsonObject["forward_from"].Value <JObject>()); } if (jsonObject["forward_date"] != null) { ForwardDateUnix = jsonObject["forward_date"].Value <int>(); ForwardDate = ForwardDateUnix.ToDateTime(); } if (jsonObject["reply_to_message"] != null) { ReplyToMessage = new MessageInfo(jsonObject["reply_to_message"].Value <JObject>()); } if (jsonObject["text"] != null) { Text = jsonObject["text"].Value <string>(); } if (jsonObject["audio"] != null) { Audio = new AudioInfo(jsonObject["audio"].Value <JObject>()); } if (jsonObject["document"] != null) { Document = new DocumentInfo(jsonObject["document"].Value <JObject>()); } if (jsonObject["photo"] != null) { Photo = PhotoSizeInfo.ParseArray(jsonObject["photo"].Value <JArray>()); } if (jsonObject["sticker"] != null) { Sticker = new StickerInfo(jsonObject["sticker"].Value <JObject>()); } if (jsonObject["video"] != null) { Video = new VideoInfo(jsonObject["video"].Value <JObject>()); } if (jsonObject["contact"] != null) { Contact = new ContactInfo(jsonObject["contact"].Value <JObject>()); } if (jsonObject["location"] != null) { Location = new LocationInfo(jsonObject["location"].Value <JObject>()); } if (jsonObject["new_chat_participant"] != null) { NewChatParticipant = new UserInfo(jsonObject["new_chat_participant"].Value <JObject>()); } if (jsonObject["left_chat_participant"] != null) { LeftChatParticipant = new UserInfo(jsonObject["left_chat_participant"].Value <JObject>()); } if (jsonObject["new_chat_title"] != null) { NewChatTitle = jsonObject["new_chat_title"].Value <string>(); } if (jsonObject["new_chat_photo"] != null) { NewChatPhoto = PhotoSizeInfo.ParseArray(jsonObject["new_chat_photo"].Value <JArray>()); } if (jsonObject["delete_chat_photo"] != null) { DeleteChatPhoto = true; } if (jsonObject["group_chat_created"] != null) { GroupChatCreated = true; } }