当前位置: 首页>>代码示例>>C#>>正文


C# GraphNode.ForEach方法代码示例

本文整理汇总了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;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:67,代码来源:DependencyWalker.cs

示例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);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:61,代码来源:RestoreGraph.cs


注:本文中的GraphNode.ForEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。