Esempio n. 1
0
 private void OnNoisyCollectionReset()
 {
     if (CollectionReset != null)
     {
         CollectionReset.Invoke();
     }
 }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 4
0
        /// <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();
            }
        }
Esempio n. 5
0
        /// <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();
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Raises the <see cref="CollectionReset"/> event.
 /// </summary>
 private void OnCollectionReset() =>
 CollectionReset?.Invoke(this);