support returning multiple instances from elements built by Build Element Methods

This commit is contained in:
Michael Becker 2024-12-21 00:23:28 -05:00
parent 1cdfb21bdd
commit 7beeffd9ad

View File

@ -172,8 +172,21 @@ public class Element : Widget
InstanceHandle workSet = OMS.Execute(context, loopExecutable);
object? obj = context.GetWorkData(workSet);
if (obj is IEnumerable<InstanceHandle> list)
IEnumerable<InstanceHandle> list;
if (obj is IEnumerable<InstanceHandle> list2)
{
list = list2;
}
else if (obj is InstanceHandle)
{
list = new InstanceHandle[] { (InstanceHandle)obj };
}
else
{
list = new InstanceHandle[0];
}
JsonArray ary = new JsonArray();
foreach (InstanceHandle ih in list)
{
@ -219,7 +232,4 @@ public class Element : Widget
}
return ary;
}
return null;
}
}