private void OnNoisyCollectionReset() { if (CollectionReset != null) { CollectionReset.Invoke(); } }
/// <summary> /// ステージされたデータをすべて破棄し、Itemsを再構築します。 /// 初期要素数はinitialSizeになります。 /// </summary> /// <returns></returns> public async Task ResetCollection() { if (_prevCancelToken != null) { _prevCancelToken.Cancel(); _prevCancelToken.Dispose(); } try { _prevCancelToken = new CancellationTokenSource(); await UpdateProxyAsync(_prevCancelToken.Token); } catch (TaskCanceledException) { return; } _collectionChangedTrigger.OnNext(CollectionChanged <T> .Reset); int i = 0; foreach (var item in _proxy.Take(_initialSize).ToArray()) { _collectionChangedTrigger.OnNext(CollectionChanged <T> .Add(i++, item)); } CollectionReset?.Invoke(this, EventArgs.Empty); _prevCancelToken.Dispose(); _prevCancelToken = null; }
/// <summary> /// Raises the <see cref="CollectionReset"/> event. /// </summary> protected virtual void OnCollectionReset() { CollectionReset?.Invoke(this); if (suppressUntypedNotifications) { return; } untypedCollectionReset?.Invoke(this); }
/// <summary> /// Removes all the items from the collection, then notifies the change /// </summary> public void Clear() { var backup = _source.ToArray(); _source.Clear(); OnCollectionChanged(backup, null); if (CollectionReset != null) { CollectionReset.Invoke(); } }
/// <summary> /// Removes all the items from the collection, then notifies the change /// </summary> public void Clear() { IList <T> backup; lock (asynclock) { backup = _source.ToArray(); _source.Clear(); } OnCollectionChanged(backup, null); if (CollectionReset != null) { CollectionReset.Invoke(); } }
/// <summary> /// Raises the <see cref="CollectionReset"/> event. /// </summary> private void OnCollectionReset() => CollectionReset?.Invoke(this);