// ------------------------------------------------------------------------------
//
// 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.AI.Workflows.Declarative.Interpreter;
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 RootTemplate : CodeTemplate, IModeledAction
{
///
/// Create the template output
///
public override string TransformText()
{
this.Write("\n");
this.Write("\n");
this.Write("\n");
this.Write("\n");
this.Write("\n/// \n/// The root executor for a declarative workflow.\n/// \ni" +
"nternal sealed class ");
this.Write(this.ToStringHelper.ToStringWithCulture(this.TypeName));
this.Write("Executor(\n DeclarativeWorkflowOptions options,\n Func inputTransform) :\n RootExecutor(\"");
this.Write(this.ToStringHelper.ToStringWithCulture(this.Id));
this.Write("\", options, inputTransform)\n where TInput : notnull\n{\n protected override a" +
"sync ValueTask ExecuteAsync(TInput message, IWorkflowContext context, Cancellati" +
"onToken cancellationToken)\n {");
if (this.TypeInfo.EnvironmentVariables.Count > 0)
{
this.Write("\n // Set environment variables\n await this.InitializeEnvironmentAsy" +
"nc(\n context,");
int index = this.TypeInfo.EnvironmentVariables.Count - 1;
foreach (string variableName in this.TypeInfo.EnvironmentVariables)
{
this.Write("\n \"");
this.Write(this.ToStringHelper.ToStringWithCulture(variableName));
this.Write("\"");
this.Write(this.ToStringHelper.ToStringWithCulture(index > 0 ? "," : ""));
--index;
}
this.Write(").ConfigureAwait(false);\n");
}
if (this.TypeInfo.UserVariables.Count > 0)
{
this.Write("\n // Initialize variables");
foreach (VariableInformationDiagnostic variableInfo in this.TypeInfo.UserVariables)
{
this.Write("\n await context.QueueStateUpdateAsync(\"");
this.Write(this.ToStringHelper.ToStringWithCulture(variableInfo.Path.VariableName));
this.Write("\", UnassignedValue.Instance, \"");
this.Write(this.ToStringHelper.ToStringWithCulture(variableInfo.Path.NamespaceAlias));
this.Write("\").ConfigureAwait(false);");
}
}
this.Write("\n }\n}\n");
return this.GenerationEnvironment.ToString();
}
}
}