// ------------------------------------------------------------------------------ // // 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.AI.Workflows.Declarative.Extensions; 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 SetTextVariableTemplate : ActionTemplate { /// /// Create the template output /// public override string TransformText() { this.Write("\n"); this.Write("\n"); this.Write("\n"); this.Write("\n"); this.Write("\n"); this.Write("\n"); this.Write("\n/// \n/// Assigns an evaluated message template to the \""); this.Write(this.ToStringHelper.ToStringWithCulture(this.Model.Variable)); this.Write("\" variable.\n/// \ninternal sealed 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 protected override async ValueTask ExecuteAsync(IWorkf" + "lowContext context, CancellationToken cancellationToken)\n {"); EvaluateMessageTemplate(this.Model.Value, "textValue"); AssignVariable(this.Variable, "textValue"); 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 "); } } } void EvaluateMessageTemplate(TemplateLine templateLine, string variableName) { if (templateLine is not null) { this.Write("\n string "); this.Write(this.ToStringHelper.ToStringWithCulture(variableName)); this.Write(" =\n await context.FormatTemplateAsync(\n \"\"\""); FormatMessageTemplate(templateLine); this.Write("\n \"\"\");"); } else { this.Write("\n string? "); this.Write(this.ToStringHelper.ToStringWithCulture(variableName)); this.Write(" = null;"); } } void FormatMessageTemplate(TemplateLine line) { foreach (string text in line.ToTemplateString().ByLine()) { this.Write("\n "); this.Write(this.ToStringHelper.ToStringWithCulture(text)); } } } }