Example #1
0
        private static void MarkAsDeleted(AsyncWriteTarget.DeleteMessagesTo deleteCommand, LinkedListNode <IPersistentRepresentation> node)
        {
            while (node != null)
            {
                if (node.Value.SequenceNr <= deleteCommand.ToSequenceNr)
                {
                    var curr = node.Value;
                    node.Value = curr.Update(sequenceNr: curr.SequenceNr,
                                             persistenceId: curr.PersistenceId,
                                             isDeleted: true,
                                             sender: curr.Sender);
                }

                node = node.Next;
            }
        }
Example #2
0
        private static void DeletePermanently(AsyncWriteTarget.DeleteMessagesTo deleteCommand, LinkedListNode <IPersistentRepresentation> node, LinkedList <IPersistentRepresentation> list)
        {
            while (node != null)
            {
                if (node.Value.SequenceNr <= deleteCommand.ToSequenceNr)
                {
                    var deleted = node;
                    node = node.Next;

                    list.Remove(deleted);
                }
                else
                {
                    node = node.Next;
                }
            }
        }
Example #3
0
        private void Delete(AsyncWriteTarget.DeleteMessagesTo deleteCommand)
        {
            LinkedList <IPersistentRepresentation> list;

            if (_messages.TryGetValue(deleteCommand.PersistenceId, out list))
            {
                var node = list.First;
                if (deleteCommand.IsPermanent)
                {
                    DeletePermanently(deleteCommand, node, list);
                }
                else
                {
                    MarkAsDeleted(deleteCommand, node);
                }
            }

            Sender.Tell(new object());
        }