mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Use TFM-specialized count check: TryGetNonEnumeratedCount for NET6+, ICollection pattern for NETFX
Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/8ec28a43-e7b7-456e-8d8e-921511b4accc Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
80ca30b448
commit
27018d615d
@@ -114,7 +114,11 @@ public static class WorkflowBuilderExtensions
|
||||
|
||||
Func<object?, bool> predicate = WorkflowBuilder.CreateConditionFunc<TMessage>((Func<object?, bool>)IsAllowedType)!;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
if (targets.TryGetNonEnumeratedCount(out int count) && count == 1)
|
||||
#else
|
||||
if (targets is ICollection<ExecutorBinding> { Count: 1 })
|
||||
#endif
|
||||
{
|
||||
return builder.AddEdge(source, Throw.IfNull(targets.First(), nameof(targets)), predicate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user