< Summary

Information
Class: Elsa.Workflows.Models.Input
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Models/Input.cs
Line coverage
66%
Covered lines: 6
Uncovered lines: 3
Coverable lines: 9
Total lines: 111
Line coverage: 66.6%
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%210%
.ctor(...)100%11100%
get_Expression()100%11100%
get_Type()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Models/Input.cs

#LineLine coverage
 1using System.Text.Json.Serialization;
 2using Elsa.Expressions.Models;
 3using Elsa.Workflows.Memory;
 4
 5namespace Elsa.Workflows.Models;
 6
 7/// <summary>
 8/// A base type for the <see cref="Input{T}"/> type.
 9/// </summary>
 10public abstract class Input : Argument
 11{
 12    /// <inheritdoc />
 013    protected Input(MemoryBlockReference memoryBlockReference, Type type) : base(memoryBlockReference)
 14    {
 015        Type = type;
 016    }
 17
 18    /// <inheritdoc />
 826819    protected Input(Expression? expression, MemoryBlockReference memoryBlockReference, Type type) : base(memoryBlockRefe
 20    {
 826821        Expression = expression;
 826822        Type = type;
 826823    }
 24
 25    /// <summary>
 26    /// Gets or sets the expression.
 27    /// </summary>
 707428    public Expression? Expression { get; }
 29
 30    /// <summary>
 31    /// Gets the type of the input.
 32    /// </summary>
 33    [JsonPropertyName("typeName")]
 1283134    public Type Type { get; set; }
 35}
 36
 37/// <summary>
 38/// Represents activity input that is evaluated at runtime.
 39/// </summary>
 40public class Input<T> : Input
 41{
 42    /// <inheritdoc />
 43    public Input(MemoryBlockReference memoryBlockReference) : base(memoryBlockReference, typeof(T))
 44    {
 45    }
 46
 47    /// <inheritdoc />
 48    public Input(T literal, string? id = null) : this(new Literal<T>(literal, id))
 49    {
 50    }
 51
 52    /// <inheritdoc />
 53    public Input(Func<T> @delegate, string? id = null) : this(Expression.DelegateExpression(@delegate), new(id!))
 54    {
 55    }
 56
 57    /// <inheritdoc />
 58    public Input(Func<ExpressionExecutionContext, ValueTask<T?>> @delegate, string? id = null) : this(Expression.Delegat
 59    {
 60    }
 61
 62    /// <inheritdoc />
 63    public Input(Func<ValueTask<T?>> @delegate, string? id = null) : this(Expression.DelegateExpression(@delegate), new(
 64    {
 65    }
 66
 67    /// <inheritdoc />
 68    public Input(Func<ExpressionExecutionContext, T> @delegate, string? id = null) : this(Expression.DelegateExpression(
 69    {
 70    }
 71
 72    /// <inheritdoc />
 73    public Input(Variable variable) : base(new("Variable", variable), variable, typeof(T))
 74    {
 75    }
 76
 77    /// <inheritdoc />
 78    public Input(Output output) : base(new("Output", output), output.MemoryBlockReference(), typeof(T))
 79    {
 80    }
 81
 82    /// <inheritdoc />
 83    public Input(Literal<T> literal) : base(Expression.LiteralExpression(literal.Value), literal, typeof(T))
 84    {
 85    }
 86
 87    /// <inheritdoc />
 88    public Input(Literal literal) : base(Expression.LiteralExpression(literal.Value), literal, typeof(T))
 89    {
 90    }
 91
 92    /// <inheritdoc />
 93    public Input(ObjectLiteral<T> literal) : base(Expression.LiteralExpression(literal.Value), literal, typeof(T))
 94    {
 95    }
 96
 97    /// <inheritdoc />
 98    public Input(ObjectLiteral literal) : base(Expression.LiteralExpression(literal.Value), literal, typeof(T))
 99    {
 100    }
 101
 102    /// <inheritdoc />
 103    public Input(Expression expression, MemoryBlockReference memoryBlockReference) : base(expression, memoryBlockReferen
 104    {
 105    }
 106
 107    /// <inheritdoc />
 108    public Input(Expression expression) : this(expression, new())
 109    {
 110    }
 111}