Esempio n. 1
0
        protected async Task RemoveCoreAsync(LinkedManifest manifest, string previousKey, LinkedNode <T> previousNode, string removeKey, LinkedNode <T> removeNode, CancellationToken cancellationToken)
        {
            if (previousNode != null)
            {
                previousNode.Next = removeNode.Next;
                await StateManager.SetStateAsync(previousKey, previousNode, cancellationToken);
            }
            else
            {
                manifest.First = removeNode.Next;
            }

            if (removeNode.Next.HasValue)
            {
                var nextKey  = IndexToKey(removeNode.Next.Value);
                var nextNode = await StateManager.GetStateAsync <LinkedNode <T> >(nextKey, cancellationToken);

                nextNode.Previous = removeNode.Previous;
                await StateManager.SetStateAsync(nextKey, nextNode, cancellationToken);
            }
            else
            {
                manifest.Last = removeNode.Previous;
            }

            await StateManager.RemoveStateAsync(removeKey, cancellationToken);

            manifest.Count--;
            if (manifest.Count == 0)
            {
                manifest.Next = 0;
            }
            await StateManager.SetStateAsync(Name, manifest, cancellationToken);
        }
Esempio n. 2
0
 protected static long NextIndex(LinkedManifest manifest)
 {
     return(manifest.Next++);
 }