< Summary

Information
Class: Elsa.Workflows.Runtime.WorkflowHostFactory
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/WorkflowHostFactory.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 45
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
CreateAsync()0%2040%
CreateAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/WorkflowHostFactory.cs

#LineLine coverage
 1using Elsa.Workflows.Models;
 2using Elsa.Workflows.Runtime.Options;
 3using Elsa.Workflows.State;
 4using Microsoft.Extensions.DependencyInjection;
 5
 6namespace Elsa.Workflows.Runtime;
 7
 8/// <inheritdoc />
 9[Obsolete("Use IWorkflowRuntime, IWorkflowRunner and IWorkflowInvoker services instead.")]
 10public class WorkflowHostFactory : IWorkflowHostFactory
 11{
 12    private readonly IIdentityGenerator _identityGenerator;
 13    private readonly IServiceProvider _serviceProvider;
 14
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="WorkflowHostFactory"/> class.
 17    /// </summary>
 018    public WorkflowHostFactory(IIdentityGenerator identityGenerator, IServiceProvider serviceProvider)
 19    {
 020        _identityGenerator = identityGenerator;
 021        _serviceProvider = serviceProvider;
 022    }
 23
 24    /// <inheritdoc />
 25    public async Task<IWorkflowHost> CreateAsync(WorkflowGraph workflowGraph, WorkflowHostOptions? options = null, Cance
 26    {
 027        var workflow = workflowGraph.Workflow;
 028        var newWorkflowInstanceId = options?.NewWorkflowInstanceId ?? _identityGenerator.GenerateId();
 029        var workflowState = new WorkflowState
 030        {
 031            Id = newWorkflowInstanceId,
 032            DefinitionId = workflow.Identity.DefinitionId,
 033            DefinitionVersion = workflow.Identity.Version
 034        };
 35
 036        return await CreateAsync(workflowGraph, workflowState, cancellationToken);
 037    }
 38
 39    /// <inheritdoc />
 40    public Task<IWorkflowHost> CreateAsync(WorkflowGraph workflowGraph, WorkflowState workflowState, CancellationToken c
 41    {
 042        var workflowHost = (IWorkflowHost)ActivatorUtilities.CreateInstance<WorkflowHost>(_serviceProvider, workflowGrap
 043        return Task.FromResult(workflowHost);
 44    }
 45}