本文整理汇总了C#中Dynamo.Nodes.List.AsEnumerable方法的典型用法代码示例。如果您正苦于以下问题:C# List.AsEnumerable方法的具体用法?C# List.AsEnumerable怎么用?C# List.AsEnumerable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Nodes.List
的用法示例。
在下文中一共展示了List.AsEnumerable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNodesFromElementIds
/// <summary>
/// This function gets the nodes which have created the elements with the
/// given element IDs
/// </summary>
/// <param name="ids">The given element IDs</param>
/// <returns>the related nodes</returns>
public static IEnumerable<NodeModel> GetNodesFromElementIds(IEnumerable<ElementId> ids)
{
List<NodeModel> nodes = new List<NodeModel>();
if (!ids.Any())
return nodes.AsEnumerable();
var workspace = dynSettings.Controller.DynamoModel.CurrentWorkspace;
ProtoCore.Core core = null;
if (dynSettings.Controller != null)
{
var engine = dynSettings.Controller.EngineController;
if ((engine != null) && (engine.LiveRunnerCore != null))
core = engine.LiveRunnerCore;
}
if (core == null)
return null;
// Selecting all nodes that are either a DSFunction,
// a DSVarArgFunction or a CodeBlockNodeModel into a list.
var nodeGuids = workspace.Nodes.Where((n) =>
{
return (n is DSFunction
|| (n is DSVarArgFunction)
|| (n is CodeBlockNodeModel));
}).Select((n) => n.GUID);
var nodeTraceDataList = core.GetCallsitesForNodes(nodeGuids);
List<ElementId> copiedIds = new List<ElementId>(ids);
bool areElementsFoundForThisNode;
foreach (Guid guid in nodeTraceDataList.Keys)
{
areElementsFoundForThisNode = false;
List<ElementId> idsToRemove = new List<ElementId>();
foreach (ProtoCore.CallSite cs in nodeTraceDataList[guid])
{
foreach (ProtoCore.CallSite.SingleRunTraceData srtd in cs.TraceData)
{
List<ISerializable> traceData = srtd.RecursiveGetNestedData();
foreach (ISerializable thingy in traceData)
{
SerializableId sid = thingy as SerializableId;
if (sid != null)
{
ElementId tempId = null;
foreach (var id in copiedIds)
{
if (sid.IntID == id.IntegerValue)
{
//FOUND ONE
tempId = id;
areElementsFoundForThisNode = true;
}
}
if (tempId != null)
copiedIds.Remove(tempId);
if (!copiedIds.Any())
{
if (areElementsFoundForThisNode)
{
NodeModel inm =
workspace.Nodes.Where((n) => n.GUID == guid).FirstOrDefault();
nodes.Add(inm);
}
return nodes.AsEnumerable();
}
}
}
}
}
if (areElementsFoundForThisNode)
{
NodeModel inm =
workspace.Nodes.Where((n) => n.GUID == guid).FirstOrDefault();
nodes.Add(inm);
}
}
return nodes.AsEnumerable();
}