Esempio n. 1
0
    /// <inheritdoc/>
    public async Task <Partial <EmbeddingCurrentState> > TryProject(EmbeddingCurrentState currentState, UncommittedEvents events, ExecutionContext executionContext, CancellationToken cancellationToken)
    {
        _logger.ProjectingEventsOnEmbedding(_identifier, currentState.Key, events);
        for (var i = 0; i < events.Count; i++)
        {
            var tryProject = await TryProjectOne(currentState, events[i], executionContext, cancellationToken).ConfigureAwait(false);

            if (!tryProject.Success)
            {
                return(i == 0
                    ? tryProject.Exception
                    : Partial <EmbeddingCurrentState> .PartialSuccess(currentState, tryProject.Exception));
            }
            currentState = tryProject.Result;
        }
        return(currentState);
    }