private void InitializeSaga(ISaga saga, SagaId id, ISagaState state) { if (state.Data is null) { saga.Initialize(id, state.State); } else { saga.InvokeGeneric(nameof(ISaga <object> .Initialize), id, state.State, state.Data); } }
private async Task CompensateAsync(ISaga saga, Type sagaType, ISagaContext context) { var sagaLogs = await _log.ReadAsync(saga.Id, sagaType); sagaLogs.OrderByDescending(l => l.CreatedAt) .Select(l => l.Message) .ToList() .ForEach(async message => { await((Task)saga.InvokeGeneric(nameof(ISagaAction <object> .CompensateAsync), message, context)) .ConfigureAwait(false); }); }