< Summary

Information
Class: Elsa.Workflows.Runtime.Handlers.RefreshActivityRegistry
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/RefreshActivityRegistry.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 31
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
HandleAsync()100%22100%
UpdateDefinition(...)100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/RefreshActivityRegistry.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Management.Activities.WorkflowDefinitionActivity;
 3using Elsa.Workflows.Management.Contracts;
 4using Elsa.Workflows.Runtime.Notifications;
 5using JetBrains.Annotations;
 6
 7namespace Elsa.Workflows.Runtime.Handlers;
 8
 9/// <summary>
 10/// Refreshes the <see cref="IActivityRegistry"/> for the <see cref="WorkflowDefinitionActivityProvider"/> provider when
 11/// </summary>
 12[PublicAPI]
 46713public class RefreshActivityRegistry(IWorkflowDefinitionActivityRegistryUpdater workflowDefinitionActivityRegistryUpdate
 14{
 15    /// <inheritdoc />
 16    public async Task HandleAsync(WorkflowDefinitionsReloaded notification, CancellationToken cancellationToken)
 17    {
 87618        foreach (var reloadedWorkflowDefinition in notification.ReloadedWorkflowDefinitions)
 43219            await UpdateDefinition(reloadedWorkflowDefinition.DefinitionVersionId, reloadedWorkflowDefinition.UsableAsAc
 620    }
 21
 22    private Task UpdateDefinition(string definitionVersionId, bool? usableAsActivity)
 23    {
 24        // A workflow should remain in the activity registry unless no longer being marked as an activity.
 43225        if (usableAsActivity.GetValueOrDefault())
 6026            return workflowDefinitionActivityRegistryUpdater.AddToRegistry(definitionVersionId);
 27
 37228        workflowDefinitionActivityRegistryUpdater.RemoveDefinitionVersionFromRegistry(definitionVersionId);
 37229        return Task.CompletedTask;
 30    }
 31}