| | | 1 | | using Elsa.Expressions.JavaScript.TypeDefinitions.Abstractions; |
| | | 2 | | using Elsa.Expressions.JavaScript.TypeDefinitions.Models; |
| | | 3 | | using Elsa.Workflows.Helpers; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | // ReSharper disable once CheckNamespace |
| | | 7 | | namespace Elsa.Expressions.JavaScript.Activities; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Produces <see cref="FunctionDefinition"/>s for common functions. |
| | | 11 | | /// </summary> |
| | | 12 | | [UsedImplicitly] |
| | | 13 | | internal class RunJavaScriptFunctionsDefinitionProvider : FunctionDefinitionProvider |
| | | 14 | | { |
| | | 15 | | protected override IEnumerable<FunctionDefinition> GetFunctionDefinitions(TypeDefinitionContext context) |
| | | 16 | | { |
| | 0 | 17 | | if (context.ActivityTypeName != ActivityTypeNameHelper.GenerateTypeName<RunJavaScript>()) |
| | 0 | 18 | | yield break; |
| | | 19 | | |
| | 0 | 20 | | if(context.PropertyName != nameof(RunJavaScript.Script)) |
| | 0 | 21 | | yield break; |
| | | 22 | | |
| | 0 | 23 | | yield return CreateFunctionDefinition(builder => builder |
| | 0 | 24 | | .Name("setOutcome") |
| | 0 | 25 | | .Parameter("name", "string") |
| | 0 | 26 | | .ReturnType("void")); |
| | | 27 | | |
| | 0 | 28 | | yield return CreateFunctionDefinition(builder => builder |
| | 0 | 29 | | .Name("setOutcomes") |
| | 0 | 30 | | .Parameter("names", "string[]") |
| | 0 | 31 | | .ReturnType("void")); |
| | 0 | 32 | | } |
| | | 33 | | } |