// ------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version: 18.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen { using Microsoft.Agents.ObjectModel; using System; /// /// Class to produce the template output /// [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "18.0.0.0")] internal partial class ParseValueTemplate : ActionTemplate { /// /// Create the template output /// public override string TransformText() { this.Write("\n"); this.Write("\n"); this.Write("\n"); this.Write("\n"); this.Write("\n/// \n/// Parses a string or untyped value to the provided data type. Wh" + "en the input is a string, it will be treated as JSON.\n/// \ninternal se" + "aled class "); this.Write(this.ToStringHelper.ToStringWithCulture(this.Name)); this.Write("Executor(FormulaSession session) : ActionExecutor(id: \""); this.Write(this.ToStringHelper.ToStringWithCulture(this.Id)); this.Write("\", session)\n{\n // \n protected override async ValueTask ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken)\n " + " { \n VariableType targetType = "); this.Write(this.ToStringHelper.ToStringWithCulture(this.GetVariableType())); this.Write(";"); if (this.Model.Value.IsVariableReference && this.Model.Value.VariableReference.SegmentCount == 2) { this.Write("\n object? parsedValue = await context.ConvertValueAsync(targetType, key: \"" + ""); this.Write(this.ToStringHelper.ToStringWithCulture(this.Model.Value.VariableReference.VariableName)); this.Write("\", scopeName: \""); this.Write(this.ToStringHelper.ToStringWithCulture(this.Model.Value.VariableReference.NamespaceAlias)); this.Write("\", cancellationToken).ConfigureAwait(false);"); } else if (this.Model.Value.IsVariableReference) { this.Write("\n object? parsedValue = await context.ConvertValueAsync(targetType, "); this.Write(this.ToStringHelper.ToStringWithCulture(FormatStringValue(this.Model.Value.VariableReference.ToString()))); this.Write(", cancellationToken).ConfigureAwait(false);"); } else { this.Write("\n object? parsedValue = await context.ConvertValueAsync(targetType, "); this.Write(this.ToStringHelper.ToStringWithCulture(FormatStringValue(this.Model.Value.ExpressionText))); this.Write(", cancellationToken).ConfigureAwait(false);"); } AssignVariable(this.Variable, "parsedValue"); this.Write("\n return default;\n }\n}"); return this.GenerationEnvironment.ToString(); } void AssignVariable(PropertyPath targetVariable, string valueVariable, bool tightFormat = false) { if (targetVariable is not null) { this.Write("\n await context.QueueStateUpdateAsync(key: \""); this.Write(this.ToStringHelper.ToStringWithCulture(VariableName(targetVariable))); this.Write("\", value: "); this.Write(this.ToStringHelper.ToStringWithCulture(valueVariable)); this.Write(", scopeName: \""); this.Write(this.ToStringHelper.ToStringWithCulture(VariableScope(targetVariable))); this.Write("\").ConfigureAwait(false);"); if (!tightFormat) { this.Write("\n "); } } } } }