| | | 1 | | using System.ComponentModel; |
| | | 2 | | using System.Runtime.CompilerServices; |
| | | 3 | | using System.Text.Json.Serialization; |
| | | 4 | | using Elsa.Expressions.Models; |
| | | 5 | | using Elsa.Workflows.Attributes; |
| | | 6 | | using Elsa.Workflows.Memory; |
| | | 7 | | using Elsa.Workflows.Models; |
| | | 8 | | |
| | | 9 | | namespace Elsa.Workflows.Activities; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Write a line of text to the console. |
| | | 13 | | /// </summary> |
| | | 14 | | [Activity("Elsa", "Console", "Write a line of text to the console.")] |
| | | 15 | | public class WriteLine : CodeActivity |
| | | 16 | | { |
| | | 17 | | /// <inheritdoc /> |
| | | 18 | | [JsonConstructor] |
| | 1865 | 19 | | private WriteLine(string? source = null, int? line = null) : base(source, line) |
| | | 20 | | { |
| | 1865 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | 1118 | 24 | | public WriteLine(string text, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(ne |
| | | 25 | | { |
| | 1118 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <inheritdoc /> |
| | | 29 | | public WriteLine(Func<string> text, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) |
| | 0 | 30 | | : this(Expression.DelegateExpression(text), source, line) |
| | | 31 | | { |
| | 0 | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <inheritdoc /> |
| | | 35 | | public WriteLine(Func<ExpressionExecutionContext, string?> text, [CallerFilePath] string? source = null, [CallerLine |
| | 200 | 36 | | : this(Expression.DelegateExpression(text), source, line) |
| | | 37 | | { |
| | 200 | 38 | | } |
| | | 39 | | |
| | | 40 | | /// <inheritdoc /> |
| | 0 | 41 | | public WriteLine(Variable<string> variable, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = n |
| | | 42 | | |
| | | 43 | | /// <inheritdoc /> |
| | 2236 | 44 | | public WriteLine(Literal<string> literal, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = nul |
| | | 45 | | |
| | | 46 | | /// <inheritdoc /> |
| | 400 | 47 | | public WriteLine(Expression expression, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) |
| | | 48 | | |
| | | 49 | | /// <inheritdoc /> |
| | 2 | 50 | | public WriteLine(Input<string> text, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// The text to write. |
| | | 54 | | /// </summary> |
| | | 55 | | [Description("The text to write.")] |
| | 6628 | 56 | | public Input<string> Text { get; set; } = null!; |
| | | 57 | | |
| | | 58 | | /// <inheritdoc /> |
| | | 59 | | protected override void Execute(ActivityExecutionContext context) |
| | | 60 | | { |
| | 558 | 61 | | var text = context.Get(Text); |
| | 558 | 62 | | var provider = context.GetService<IStandardOutStreamProvider>() ?? new StandardOutStreamProvider(System.Console. |
| | 558 | 63 | | var textWriter = provider.GetTextWriter(); |
| | 558 | 64 | | textWriter.WriteLine(text); |
| | 558 | 65 | | } |
| | | 66 | | } |