< Summary

Information
Class: Elsa.Workflows.Runtime.Notifications.DispatchWorkflowActivationDenied
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Notifications/DispatchWorkflowActivationDenied.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 48
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_ParentWorkflowInstanceId()100%11100%
get_WorkflowInstanceId()100%11100%
get_ActivityTypeName()100%11100%
get_StimulusHash()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Notifications/DispatchWorkflowActivationDenied.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2
 3namespace Elsa.Workflows.Runtime.Notifications;
 4
 5/// <summary>
 6/// Signals that a queued child-workflow dispatch was accepted but activation was denied.
 7/// </summary>
 78internal sealed record DispatchWorkflowActivationDenied(
 69    string ParentWorkflowInstanceId,
 610    string WorkflowInstanceId,
 911    string ActivityTypeName,
 1312    string StimulusHash) : INotification;
 13
 14/// <summary>
 15/// Carries an internal bookmark-resume route through queued definition dispatch without persisting it on a child instan
 16/// </summary>
 17internal static class DispatchWorkflowActivationDeniedRoute
 18{
 19    private const string ActivityTypeNameKey = "__elsa.internal.dispatch-activation-denied.activity-type-name";
 20    private const string StimulusHashKey = "__elsa.internal.dispatch-activation-denied.stimulus-hash";
 21
 22    public static void Add(IDictionary<string, object> properties, string activityTypeName, string stimulusHash)
 23    {
 24        properties[ActivityTypeNameKey] = activityTypeName;
 25        properties[StimulusHashKey] = stimulusHash;
 26    }
 27
 28    public static IDictionary<string, object>? SanitizeAndRead(IDictionary<string, object>? properties, out (string Acti
 29    {
 30        route = null;
 31
 32        if (properties == null)
 33            return null;
 34
 35        if (!properties.ContainsKey(ActivityTypeNameKey) && !properties.ContainsKey(StimulusHashKey))
 36            return properties;
 37
 38        // Do not mutate the caller's property bag: it may be shared with dispatch notification handlers.
 39        var sanitizedProperties = new Dictionary<string, object>(properties);
 40        var hasActivityTypeName = sanitizedProperties.Remove(ActivityTypeNameKey, out var activityTypeNameValue);
 41        var hasStimulusHash = sanitizedProperties.Remove(StimulusHashKey, out var stimulusHashValue);
 42
 43        if (hasActivityTypeName && hasStimulusHash && activityTypeNameValue is string activityTypeName && !string.IsNull
 44            route = (activityTypeName, stimulusHash);
 45
 46        return sanitizedProperties;
 47    }
 48}