Ejemplo n.º 1
0
        /// <summary> Разобрать из json. </summary>
        /// <param name="response">Ответ сервера.</param>
        /// <returns></returns>
        public static EditMessage FromJson(VkResponseArray response)
        {
            var editMessage = new EditMessage();

            editMessage.InitializeStandartFields(response);
            editMessage.MessageId = (ulong)response[1];
            editMessage.Mask      = (ulong)response[2];
            editMessage.PeerId    = (ulong)response[3];
            editMessage.Ts        = (ulong)response[4];
            editMessage.NewText   = (string)response[5];

            return(editMessage);
        }
Ejemplo n.º 2
0
 /// <summary>Разобрать из json.</summary>
 /// <param name="response">Ответ сервера.</param>
 /// <returns></returns>
 public static Update FromJson(VkResponseArray response)
 {
     var update = new Update();
       var code = (int) response.First();
       switch (code)
       {
     case 4:
       update.Type = typeof (NewMessage);
       update.NewMessage = NewMessage.FromJson(response);
       break;
     case 5:
       update.Type = typeof (EditMessage);
       update.EditMessage = EditMessage.FromJson(response);
       break;
     case 6:
       update.Type = typeof (ReadAllIncomingMessages);
       update.ReadAllIncomingMessages = ReadAllIncomingMessages.FromJson(response);
       break;
     case 7:
       update.Type = typeof (ReadAllOutcomingMessages);
       update.ReadAllOutcomingMessages = ReadAllOutcomingMessages.FromJson(response);
       break;
     case 8:
       update.Type = typeof (FriendBecameOnline);
       update.FriendBecameOnline = FriendBecameOnline.FromJson(response);
       break;
     case 9:
       update.Type = typeof (FriendBecameOffline);
       update.FriendBecameOffline = FriendBecameOffline.FromJson(response);
       break;
     case 61:
       update.Type = typeof (UserTypingInPrivateDialog);
       update.UserTypingInPrivateDialog = UserTypingInPrivateDialog.FromJson(response);
       break;
     default:
       throw new InvalidParameterException($"The type '{(object) code}' of event is not defined.");
       }
       return update;
 }