mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
34 lines
1.4 KiB
Plaintext
34 lines
1.4 KiB
Plaintext
<#@ template language="C#" inherits="ActionTemplate" visibility="internal" linePragmas="false" #>
|
|
<#@ output extension=".cs" #>
|
|
<#@ assembly name="System.Core" #>
|
|
<#@ import namespace="Microsoft.Agents.AI.Workflows.Declarative.ObjectModel" #>
|
|
<#@ import namespace="Microsoft.Agents.ObjectModel" #>
|
|
<#@ include file="Snippets/AssignVariableTemplate.tt" once="true" #>
|
|
<#@ include file="Snippets/EvaluateBoolExpressionTemplate.tt" once="true" #>
|
|
/// <summary>
|
|
/// Conditional branching similar to an if / elseif / elseif / else chain.
|
|
/// </summary>
|
|
internal sealed class <#= this.Name #>Executor(FormulaSession session) : ActionExecutor(id: "<#= this.Id #>", session)
|
|
{
|
|
// <inheritdoc />
|
|
protected override async ValueTask<object?> ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken)
|
|
{<#
|
|
for (int index = 0; index < this.Model.Conditions.Length; ++index)
|
|
{
|
|
ConditionItem conditionItem = this.Model.Conditions[index];
|
|
if (conditionItem.Condition is null)
|
|
{
|
|
continue; // Skip if no condition is defined
|
|
}
|
|
|
|
EvaluateBoolExpression(conditionItem.Condition, $"condition{index}");#>
|
|
if (condition<#= index #>)
|
|
{
|
|
return "<#= ConditionGroupExecutor.Steps.Item(this.Model, conditionItem)#>";
|
|
}
|
|
<#
|
|
}
|
|
#>
|
|
return "<#= ConditionGroupExecutor.Steps.Else(this.Model)#>";
|
|
}
|
|
} |