mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Preserve Throw helper validation style
Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/af831ee2-0a99-4427-9ffd-a3b5022c1b3b Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
5ce002d3fd
commit
824ee2111b
@@ -37,13 +37,9 @@ public sealed class SwitchBuilder
|
||||
|
||||
HashSet<int> indicies = [];
|
||||
|
||||
int executorIndex = 0;
|
||||
foreach (ExecutorBinding? executor in executors)
|
||||
foreach (ExecutorBinding executor in executors)
|
||||
{
|
||||
if (executor is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(executors), $"Executors collection contains a null element at index {executorIndex}.");
|
||||
}
|
||||
Throw.IfNull(executor, nameof(executors));
|
||||
|
||||
if (!this._executorIndicies.TryGetValue(executor.Id, out int index))
|
||||
{
|
||||
@@ -53,7 +49,6 @@ public sealed class SwitchBuilder
|
||||
}
|
||||
|
||||
indicies.Add(index);
|
||||
executorIndex++;
|
||||
}
|
||||
|
||||
Func<object?, bool> casePredicate = WorkflowBuilder.CreateConditionFunc(predicate)!;
|
||||
@@ -71,13 +66,9 @@ public sealed class SwitchBuilder
|
||||
{
|
||||
Throw.IfNull(executors);
|
||||
|
||||
int executorIndex = 0;
|
||||
foreach (ExecutorBinding? executor in executors)
|
||||
foreach (ExecutorBinding executor in executors)
|
||||
{
|
||||
if (executor is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(executors), $"Executors collection contains a null element at index {executorIndex}.");
|
||||
}
|
||||
Throw.IfNull(executor, nameof(executors));
|
||||
|
||||
if (!this._executorIndicies.TryGetValue(executor.Id, out int index))
|
||||
{
|
||||
@@ -87,7 +78,6 @@ public sealed class SwitchBuilder
|
||||
}
|
||||
|
||||
this._defaultIndicies.Add(index);
|
||||
executorIndex++;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
@@ -127,27 +127,15 @@ public static class WorkflowBuilderExtensions
|
||||
{
|
||||
Throw.IfNull(targets);
|
||||
|
||||
List<ExecutorBinding> targetList = [];
|
||||
using IEnumerator<ExecutorBinding> targetEnumerator = targets.GetEnumerator();
|
||||
if (!targetEnumerator.MoveNext())
|
||||
List<ExecutorBinding> targetList = new();
|
||||
foreach (ExecutorBinding target in targets)
|
||||
{
|
||||
throw new ArgumentException("Targets collection cannot be empty.", nameof(targets));
|
||||
}
|
||||
|
||||
int targetIndex = 0;
|
||||
do
|
||||
{
|
||||
ExecutorBinding? target = targetEnumerator.Current;
|
||||
if (target is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(targets), $"Targets collection contains a null element at index {targetIndex}.");
|
||||
}
|
||||
Throw.IfNull(target, nameof(targets));
|
||||
|
||||
targetList.Add(target);
|
||||
targetIndex++;
|
||||
}
|
||||
while (targetEnumerator.MoveNext());
|
||||
|
||||
Throw.IfNullOrEmpty(targetList, nameof(targets));
|
||||
return targetList;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user