mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Inline ValidateTargets into call sites
Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/cb9a6a6a-02c7-41a8-a4b4-da16ad62ef86 Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
e6f194bce5
commit
2af97e5a7f
@@ -57,9 +57,18 @@ public static class WorkflowBuilderExtensions
|
||||
{
|
||||
Throw.IfNull(builder);
|
||||
Throw.IfNull(source);
|
||||
Throw.IfNull(targets);
|
||||
|
||||
Func<object?, bool> predicate = WorkflowBuilder.CreateConditionFunc<TMessage>(IsAllowedTypeAndMatchingCondition)!;
|
||||
List<ExecutorBinding> targetList = ValidateTargets(targets);
|
||||
List<ExecutorBinding> targetList = new();
|
||||
foreach (ExecutorBinding target in targets)
|
||||
{
|
||||
Throw.IfNull(target, nameof(targets));
|
||||
|
||||
targetList.Add(target);
|
||||
}
|
||||
|
||||
Throw.IfNullOrEmpty(targetList, nameof(targets));
|
||||
|
||||
if (targetList.Count == 1)
|
||||
{
|
||||
@@ -100,9 +109,18 @@ public static class WorkflowBuilderExtensions
|
||||
{
|
||||
Throw.IfNull(builder);
|
||||
Throw.IfNull(source);
|
||||
Throw.IfNull(targets);
|
||||
|
||||
Func<object?, bool> predicate = WorkflowBuilder.CreateConditionFunc<TMessage>((Func<object?, bool>)IsAllowedType)!;
|
||||
List<ExecutorBinding> targetList = ValidateTargets(targets);
|
||||
List<ExecutorBinding> targetList = new();
|
||||
foreach (ExecutorBinding target in targets)
|
||||
{
|
||||
Throw.IfNull(target, nameof(targets));
|
||||
|
||||
targetList.Add(target);
|
||||
}
|
||||
|
||||
Throw.IfNullOrEmpty(targetList, nameof(targets));
|
||||
|
||||
if (targetList.Count == 1)
|
||||
{
|
||||
@@ -116,29 +134,6 @@ public static class WorkflowBuilderExtensions
|
||||
static bool IsAllowedType(object? message) => message is null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates a target collection and returns it as a list.
|
||||
/// </summary>
|
||||
/// <param name="targets">The target executor bindings to validate.</param>
|
||||
/// <returns>A validated list of target executor bindings.</returns>
|
||||
/// <exception cref="ArgumentNullException">Thrown when <paramref name="targets"/> is null or contains a null element.</exception>
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="targets"/> is empty.</exception>
|
||||
private static List<ExecutorBinding> ValidateTargets(IEnumerable<ExecutorBinding> targets)
|
||||
{
|
||||
Throw.IfNull(targets);
|
||||
|
||||
List<ExecutorBinding> targetList = new();
|
||||
foreach (ExecutorBinding target in targets)
|
||||
{
|
||||
Throw.IfNull(target, nameof(targets));
|
||||
|
||||
targetList.Add(target);
|
||||
}
|
||||
|
||||
Throw.IfNullOrEmpty(targetList, nameof(targets));
|
||||
return targetList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a sequential chain of executors to the workflow, connecting each executor in order so that each is
|
||||
/// executed after the previous one.
|
||||
|
||||
Reference in New Issue
Block a user