示例#1
0
        /// <summary> Разобрать из json. </summary>
        /// <param name="response">Ответ сервера.</param>
        /// <returns></returns>
        public static FriendBecameOnline FromJson(VkResponseArray response)
        {
            var friendBecameOnline = new FriendBecameOnline();

            friendBecameOnline.InitializeStandartFields(response);
            friendBecameOnline.UserId = -((long)response[1]);
            friendBecameOnline.Extra  = (ulong)response[2];
            friendBecameOnline.Ts     = (ulong)response[3];
            return(friendBecameOnline);
        }
示例#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;
 }