private async Task RunActionsAsync(WaivesDocument document, CancellationToken cancellationToken = default) { foreach (var documentAction in _documentActions) { document = await documentAction(document, cancellationToken).ConfigureAwait(false); } }
public async Task RunAsync(Document document, CancellationToken cancellationToken = default) { WaivesDocument waivesDocument = null; try { waivesDocument = await _documentCreator(document, cancellationToken); await RunActionsAsync(waivesDocument, cancellationToken).ConfigureAwait(false); } catch (Exception e) { _onDocumentException(e, document); } finally { if (waivesDocument != null) { await _documentDeleter(waivesDocument); } } }