< Summary

Information
Class: Elsa.Workflows.Runtime.NewWorkflowInboxMessage
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Models/NewWorkflowInboxMessage.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 18
Coverable lines: 18
Total lines: 78
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%210%
get_ActivityTypeName()100%210%
get_BookmarkPayload()100%210%
get_WorkflowInstanceId()100%210%
get_ActivityInstanceId()100%210%
get_CorrelationId()100%210%
get_Input()100%210%
get_TimeToLive()100%210%
For(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Models/NewWorkflowInboxMessage.cs

#LineLine coverage
 1using Elsa.Workflows.Helpers;
 2
 3namespace Elsa.Workflows.Runtime;
 4
 5/// <summary>
 6/// A message that can be delivered to a workflow instance.
 7/// </summary>
 8[Obsolete("This class will be removed in a future version.")]
 9public class NewWorkflowInboxMessage
 10{
 011    private static readonly TimeSpan DefaultTimeToLive = TimeSpan.FromMinutes(1);
 12
 13    /// <summary>
 14    /// The type name of the activity to deliver the message to.
 15    /// </summary>
 016    public string ActivityTypeName { get; set; } = default!;
 17
 18    /// <summary>
 19    /// An optional bookmark payload that can be used to filter the workflow instances to deliver the message to.
 20    /// </summary>
 021    public object BookmarkPayload { get; set; } = default!;
 22
 23    /// <summary>
 24    /// An optional workflow instance ID to select the workflow instance to deliver the message to.
 25    /// </summary>
 026    public string? WorkflowInstanceId { get; set; }
 27
 28    /// <summary>
 29    /// An optional activity instance ID to select the workflow instance to deliver the message to.
 30    /// </summary>
 031    public string? ActivityInstanceId { get; set; }
 32
 33    /// <summary>
 34    /// An optional correlation ID to select the workflow instance to deliver the message to.
 35    /// </summary>
 036    public string? CorrelationId { get; set; }
 37
 38    /// <summary>
 39    /// An optional set of inputs to deliver to the workflow instance.
 40    /// </summary>
 041    public IDictionary<string, object>? Input { get; set; }
 42
 43    /// <summary>
 44    /// The duration after which the message expires.
 45    /// </summary>
 046    public TimeSpan TimeToLive { get; set; } = DefaultTimeToLive;
 47
 48    /// <summary>
 49    /// Creates a new instance of the <see cref="NewWorkflowInboxMessage"/> class.
 50    /// </summary>
 51    /// <param name="bookmarkPayload">The bookmark payload to use to filter the workflow instances to deliver the messag
 52    /// <param name="workflowInstanceId">An optional workflow instance ID to select the workflow instance to deliver the
 53    /// <param name="correlationId">An optional correlation ID to select the workflow instance to deliver the message to
 54    /// <param name="activityInstanceId">An optional activity instance ID to select the workflow instance to deliver the
 55    /// <param name="input">An optional set of inputs to deliver to the workflow instance.</param>
 56    /// <param name="timeToLive">The duration after which the message expires.</param>
 57    /// <typeparam name="T">The type of the activity to deliver the message to.</typeparam>
 58    /// <returns>A new instance of the <see cref="NewWorkflowInboxMessage"/> class.</returns>
 59    public static NewWorkflowInboxMessage For<T>(
 60        object bookmarkPayload,
 61        string? workflowInstanceId = default,
 62        string? correlationId = default,
 63        string? activityInstanceId = default,
 64        IDictionary<string, object>? input = default,
 65        TimeSpan? timeToLive = default) where T : IActivity
 66    {
 067        return new NewWorkflowInboxMessage
 068        {
 069            Input = input,
 070            BookmarkPayload = bookmarkPayload,
 071            CorrelationId = correlationId,
 072            WorkflowInstanceId = workflowInstanceId,
 073            ActivityInstanceId = activityInstanceId,
 074            ActivityTypeName = ActivityTypeNameHelper.GenerateTypeName<T>(),
 075            TimeToLive = timeToLive ?? DefaultTimeToLive,
 076        };
 77    }
 78}