Exemplo n.º 1
0
        /// <inheritdoc/>
        public async Task UpdateAsync(IImmutable <TEntity> newValue, CancellationToken ct = default)
        {
            if (newValue == null)
            {
                if (_store.ContainsKey(_id))
                {
                    newValue = _store[_id];
                    _store.Remove(_id);
                    await _notifier.StateItemRemovedAsync(_id, newValue, ct);
                }
            }
            else
            {
                if (_store.ContainsKey(_id))
                {
                    _store.AddOrUpdate(_id, newValue);
                    await _notifier.StateItemUpdatedAsync(_id, newValue, ct);
                }
                else
                {
                    _store.TryAdd(_id, newValue);
                    await _notifier.StateItemAddedAsync(_id, newValue, ct);
                }
            }

            await _notifier.StateChangedAsync(_id, newValue, ct);
        }
Exemplo n.º 2
0
 /// <inheritdoc/>
 public async Task <IImmutable <TEntity> > GetAsync(TId id, CancellationToken ct = default)
 {
     if (!_store.ContainsKey(id))
     {
         if (_defaultValueLoader == null)
         {
             return(default);