< Summary

Information
Class: Elsa.Extensions.WorkflowRunnerExtensions
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/WorkflowRunnerExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 49
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
RunUntilEndAsync()0%7280%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/WorkflowRunnerExtensions.cs

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Models;
 3using Elsa.Workflows.Options;
 4using Elsa.Workflows.State;
 5using JetBrains.Annotations;
 6
 7// ReSharper disable once CheckNamespace
 8namespace Elsa.Extensions;
 9
 10/// <summary>
 11/// Contains extension methods for <see cref="IWorkflowRunner"/>.
 12/// </summary>
 13[PublicAPI]
 14public static class WorkflowRunnerExtensions
 15{
 16    /// <summary>
 17    /// Runs a workflow until its end, automatically resuming any bookmark it encounters.
 18    /// </summary>
 19    public static async Task<WorkflowState> RunUntilEndAsync(
 20        this IWorkflowRunner workflowRunner,
 21        IActivity activity,
 22        Func<WorkflowState, Bookmark, RunWorkflowOptions, bool>? processBookmark = default,
 23        CancellationToken cancellationToken = default)
 24    {
 025        var result = await workflowRunner.RunAsync(activity, cancellationToken: cancellationToken);
 026        var workflow = result.Workflow;
 027        var workflowState = result.WorkflowState;
 028        var bookmarks = new Stack<Bookmark>(workflowState.Bookmarks);
 29
 30        // Continue resuming the workflow for as long as there are bookmarks to resume.
 031        while (bookmarks.TryPop(out var bookmark))
 32        {
 033            var options = new RunWorkflowOptions { BookmarkId = bookmark.Id };
 34
 35            // Give caller a chance to determine whether or not to resume the bookmark, as well as configure any input t
 036            if (processBookmark != null && !processBookmark(workflowState, bookmark, options))
 37                continue;
 38
 039            result = await workflowRunner.RunAsync(workflow, workflowState, options, cancellationToken: cancellationToke
 040            workflowState = result.WorkflowState;
 41
 042            foreach (var newBookmark in workflowState.Bookmarks)
 043                bookmarks.Push(newBookmark);
 44        }
 45
 46        // Return the workflow state.
 047        return workflowState;
 048    }
 49}

Methods/Properties

RunUntilEndAsync()