<#@ template language="C#" inherits="ActionTemplate" visibility="internal" linePragmas="false" #> <#@ output extension=".cs" #> <#@ assembly name="System.Core" #> <#@ import namespace="Microsoft.Agents.ObjectModel" #> <#@ include file="Snippets/AssignVariableTemplate.tt" once="true" #> /// /// Parses a string or untyped value to the provided data type. When the input is a string, it will be treated as JSON. /// internal sealed class <#= this.Name #>Executor(FormulaSession session) : ActionExecutor(id: "<#= this.Id #>", session) { // protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken) { VariableType targetType = <#= this.GetVariableType() #>;<# if (this.Model.Value.IsVariableReference && this.Model.Value.VariableReference.SegmentCount == 2) {#> object? parsedValue = await context.ConvertValueAsync(targetType, key: "<#= this.Model.Value.VariableReference.VariableName #>", scopeName: "<#= this.Model.Value.VariableReference.NamespaceAlias #>", cancellationToken).ConfigureAwait(false);<# } else if (this.Model.Value.IsVariableReference) {#> object? parsedValue = await context.ConvertValueAsync(targetType, <#= FormatStringValue(this.Model.Value.VariableReference.ToString()) #>, cancellationToken).ConfigureAwait(false);<# } else {#> object? parsedValue = await context.ConvertValueAsync(targetType, <#= FormatStringValue(this.Model.Value.ExpressionText) #>, cancellationToken).ConfigureAwait(false);<# } AssignVariable(this.Variable, "parsedValue"); #> return default; } }