Esempio n. 1
0
        internal void UpdateFromIntermediate(Action <ICacheUpdater <TObject, TKey> > updateAction)
        {
            if (updateAction == null)
            {
                throw new ArgumentNullException(nameof(updateAction));
            }

            lock (_locker)
            {
                ChangeSet <TObject, TKey> changes = null;

                _editLevel++;
                if (_editLevel == 1)
                {
                    var previewHandler = _changesPreview.HasObservers ? (Action <ChangeSet <TObject, TKey> >)InvokePreview : null;
                    changes = _readerWriter.Write(updateAction, previewHandler, _changes.HasObservers);
                }
                else
                {
                    _readerWriter.WriteNested(updateAction);
                }

                _editLevel--;

                if (_editLevel == 0)
                {
                    InvokeNext(changes);
                }
            }
        }
Esempio n. 2
0
        /// <inheritdoc />
        public void Edit([NotNull] Action <IExtendedList <T> > updateAction)
        {
            if (updateAction == null)
            {
                throw new ArgumentNullException(nameof(updateAction));
            }

            lock (_writeLock)
            {
                IChangeSet <T> changes = null;

                _editLevel++;

                if (_editLevel == 1)
                {
                    if (_changesPreview.HasObservers)
                    {
                        changes = _readerWriter.WriteWithPreview(updateAction, InvokeNextPreview);
                    }
                    else
                    {
                        changes = _readerWriter.Write(updateAction);
                    }
                }
                else
                {
                    _readerWriter.WriteNested(updateAction);
                }

                _editLevel--;

                if (_editLevel == 0)
                {
                    InvokeNext(changes);
                }
            }
        }