public virtual void ApplyAllChanges() { foreach (var @event in DomainEvents) { _eventRouter.Route(@event); } }
public virtual void ApplyEvent(object @event) { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } _eventRouter.Route(@event); AddEvent(@event as INotification); }
/// <summary> /// Runs the Rx Worker. /// </summary> /// <param name="cancellationToken">Token used to cancel the operation.</param> /// <returns>The resulting task.</returns> public async Task Run(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfNotRunning(); if (!await channel.WaitToRead(cancellationToken)) { return; } var chunk = await channel.Read(cancellationToken); await stream !.WriteAsync(chunk.Bytes, cancellationToken); if (chunk.EndOfMessage) { cancellationToken.ThrowIfCancellationRequested(); stream.Position = 0; var message = await serializer.Deserialize <GatewayMessage>(stream, cancellationToken); if (message.SequenceNumber != null) { gateway !.SequenceNumber = message.SequenceNumber; } if (message.Data != null) { _ = eventRouter.Route(message.Data, cancellationToken); } logger.LogInformation("Received message: {@message}", message); stream.SetLength(0); } }