| | | 1 | | using System.Runtime.CompilerServices; |
| | | 2 | | using Elsa.Expressions.Models; |
| | | 3 | | using Elsa.Workflows.Attributes; |
| | | 4 | | using Elsa.Workflows.Models; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Activities; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Read a line of text from the console. |
| | | 10 | | /// </summary> |
| | | 11 | | [Activity("Elsa", "Console", "Read a line of text from the console.")] |
| | | 12 | | public class ReadLine : CodeActivity<string> |
| | | 13 | | { |
| | | 14 | | /// <inheritdoc /> |
| | 8 | 15 | | public ReadLine([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) |
| | | 16 | | { |
| | 8 | 17 | | } |
| | | 18 | | |
| | | 19 | | /// <inheritdoc /> |
| | 0 | 20 | | public ReadLine(MemoryBlockReference output, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = |
| | | 21 | | { |
| | 0 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <inheritdoc /> |
| | 0 | 25 | | public ReadLine(Output<string>? output, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) |
| | | 26 | | { |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | protected override void Execute(ActivityExecutionContext context) |
| | | 31 | | { |
| | 8 | 32 | | var provider = context.GetService<IStandardInStreamProvider>() ?? new StandardInStreamProvider(Console.In); |
| | 8 | 33 | | var reader = provider.GetTextReader(); |
| | 8 | 34 | | var text = reader.ReadLine()!; |
| | 8 | 35 | | context.Set(Result, text); |
| | 8 | 36 | | } |
| | | 37 | | } |