本文整理汇总了C#中GraphNode.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# GraphNode.ForEach方法的具体用法?C# GraphNode.ForEach怎么用?C# GraphNode.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphNode
的用法示例。
在下文中一共展示了GraphNode.ForEach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Walk
public GraphNode<Library> Walk(string name, NuGetVersion version, NuGetFramework framework)
{
var key = new LibraryRange
{
Name = name,
VersionRange = new VersionRange(version)
};
var root = new GraphNode<Library>(key);
var resolvedItems = new Dictionary<LibraryRange, GraphItem<Library>>();
// Recurse through dependencies optimistically, asking resolvers for dependencies
// based on best match of each encountered dependency
root.ForEach(node =>
{
node.Item = Resolve(resolvedItems, node.Key, framework);
if (node.Item == null)
{
node.Disposition = Disposition.Rejected;
return;
}
foreach (var dependency in node.Item.Data.Dependencies)
{
// determine if a child dependency is eclipsed by
// a reference on the line leading to this point. this
// prevents cyclical dependencies, and also implements the
// "nearest wins" rule.
var eclipsed = false;
for (var scanNode = node;
scanNode != null && !eclipsed;
scanNode = scanNode.OuterNode)
{
eclipsed |= scanNode.Key.IsEclipsedBy(dependency.LibraryRange);
if (eclipsed)
{
throw new InvalidOperationException(string.Format("Circular dependency detected {0}.", GetChain(node, dependency)));
}
foreach (var sideNode in scanNode.InnerNodes)
{
eclipsed |= sideNode.Key.IsEclipsedBy(dependency.LibraryRange);
if (eclipsed)
{
break;
}
}
}
if (!eclipsed)
{
var innerNode = new GraphNode<Library>(dependency.LibraryRange)
{
OuterNode = node
};
node.InnerNodes.Add(innerNode);
}
}
});
return root;
}
示例2: Create
public static RestoreTargetGraph Create(
bool inConflict,
NuGetFramework framework,
string runtimeIdentifier,
RuntimeGraph runtimeGraph,
GraphNode<RemoteResolveResult> graph,
RemoteWalkContext context,
ILogger log)
{
var install = new HashSet<RemoteMatch>();
var flattened = new HashSet<GraphItem<RemoteResolveResult>>();
var unresolved = new HashSet<LibraryRange>();
graph.ForEach(node =>
{
if (node == null
|| node.Key == null
|| node.Disposition == Disposition.Rejected)
{
return;
}
if (node.Item == null
|| node.Item.Data.Match == null)
{
if (node.Key.TypeConstraint != LibraryTypes.Reference
&&
node.Key.VersionRange != null)
{
unresolved.Add(node.Key);
}
return;
}
if (!string.Equals(node.Item.Data.Match.Library.Name, node.Key.Name, StringComparison.Ordinal))
{
// Fix casing of the library name to be installed
node.Item.Data.Match.Library.Name = node.Key.Name;
}
// If the package came from a remote library provider, it needs to be installed locally
var isRemote = context.RemoteLibraryProviders.Contains(node.Item.Data.Match.Provider);
if (isRemote)
{
install.Add(node.Item.Data.Match);
}
flattened.Add(node.Item);
});
return new RestoreTargetGraph(
inConflict,
framework,
runtimeIdentifier,
runtimeGraph,
graph,
install,
flattened,
unresolved);
}