< Summary

Information
Class: Elsa.Workflows.PortResolvers.PropertyBasedActivityResolver
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/PortResolvers/OutboundActivityPortResolver.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 40
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
get_Priority()100%11100%
GetSupportsActivity(...)100%11100%
GetActivityPortsAsync(...)100%11100%
GetActivityPortsInternal(...)100%44100%
GetPropertyIsCollection(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/PortResolvers/OutboundActivityPortResolver.cs

#LineLine coverage
 1using System.Reflection;
 2using Elsa.Workflows.Models;
 3
 4namespace Elsa.Workflows.PortResolvers;
 5
 6/// <summary>
 7/// Returns a list of outbound activities for a given activity by reflecting over its public properties matching <see cr
 8/// </summary>
 9public class PropertyBasedActivityResolver : IActivityResolver
 10{
 11    /// <inheritdoc />
 85112    public int Priority => -1;
 13
 14    /// <inheritdoc />
 1664515    public bool GetSupportsActivity(IActivity activity) => true;
 16
 17    /// <inheritdoc />
 18    public ValueTask<IEnumerable<ActivityPort>> GetActivityPortsAsync(IActivity activity, CancellationToken cancellation
 19    {
 1664520        return new(GetActivityPortsInternal(activity));
 21    }
 22
 23    private static IEnumerable<ActivityPort> GetActivityPortsInternal(IActivity activity)
 24    {
 1664525        var activityType = activity.GetType();
 26
 1664527        var ports =
 1664528            from prop in activityType.GetProperties(BindingFlags.Public | BindingFlags.Instance)
 29904829            where typeof(IActivity).IsAssignableFrom(prop.PropertyType) || typeof(IEnumerable<IActivity>).IsAssignableFr
 1191430            let value = prop.GetValue(activity)
 1191431            let isCollection = GetPropertyIsCollection(prop.PropertyType)
 1191432            let portName = prop.Name
 1191433            where value != null
 2586034            select isCollection ? ActivityPort.FromActivities((IEnumerable<IActivity>)value, portName) : ActivityPort.Fr
 35
 1664536        return ports.ToList();
 37    }
 38
 1191439    private static bool GetPropertyIsCollection(Type propertyType) => typeof(IEnumerable<IActivity>).IsAssignableFrom(pr
 40}