private void ProcessNewUsers(IEnumerable <User> users) { if (users == null) { return; } var usersArray = users as User[] ?? users.ToArray(); if (!usersArray.Any()) { return; } _lastUserId = usersArray.Last().Id; lock (UsersStorage) { foreach (var user in usersArray) { if (!UsersStorage.ContainsKey(user.Id)) { UsersStorage.Add(user.Id, user); } } } NewUsersEvent?.Invoke(this, usersArray); }
public void SetUser(User user) { lock (UsersStorage) { if (UsersStorage.ContainsKey(user.Id)) { UsersStorage[user.Id] = user; if (_newUserInfoHandlers.ContainsKey(user.Id)) { _newUserInfoHandlers[user.Id]?.Invoke(this, user); } } else { UsersStorage.Add(user.Id, user); NewUsersEvent?.Invoke(this, new[] { user }); } } }
private void PollerOnNewUsersEvent(object sender, IEnumerable <User> enumerable) { NewUsersEvent?.Invoke(this, enumerable); }