/// <summary> /// Add/remove user id in this container. /// </summary> /// <param name="id">target user's id</param> /// <param name="value">flag for add or remove</param> public async Task SetAsync(long id, bool value) { lock (_collectionLock) { var result = value ? _collection.AddDistinct(id) : _collection.Remove(id); if (!result) { // not changed return; } } await UserProxy.SetAsync(_type, _parent.AccountId, id, value).ConfigureAwait(false); RaiseAccountDataUpdated(new[] { id }, value); }
private async Task AddAsync(IEnumerable <long> items) { var m = items.ToArray(); lock (_collectionLock) { m = m.Where(i => _collection.AddDistinct(i)).ToArray(); } if (m.Length == 0) { return; } await UserProxy.AddAsync(_type, _parent.AccountId, m); this.RaiseAccountDataUpdated(m, true); }