public static IGraphNode <LibraryDescription> Build([NotNull] IList <LibraryDescription> libraries, [NotNull] Runtime.Project project) { var libDictionary = libraries.ToDictionary(desc => desc.Identity); LibraryDescription root; if (!libDictionary.TryGetValue(new Library { Name = project.Name, Version = project.Version }, out root)) { throw new InvalidOperationException(string.Format("Failed to retrieve {0} of project {1} - {2}", typeof(LibraryDependency).Name, project.Name, project.Version)); } // build a tree of LibraryDescriptions of the given project root return(DepthFirstGraphTraversal.PostOrderWalk <LibraryDescription, IGraphNode <LibraryDescription> >( node: root, getChildren: node => { if (node.Resolved) { return node.Dependencies.Select(dependency => libDictionary[dependency.Library]); } else { return Enumerable.Empty <LibraryDescription>(); } }, visitNode: (node, children) => { return new GraphNode <LibraryDescription>(node, children); })); }
public static IGraphNode <LibraryDescription> Build([NotNull] IEnumerable <LibraryDescription> libraries, [NotNull] Runtime.Project project) { var root = libraries.FirstOrDefault(p => string.Equals(p.Identity.Name, project.Name)); if (root == null) { throw new InvalidOperationException(string.Format("Failed to retrieve {0} of project {1} - {2}", typeof(LibraryDependency).Name, project.Name, project.Version)); } // build a tree of LibraryDescriptions of the given project root return(DepthFirstGraphTraversal.PostOrderWalk <LibraryDescription, IGraphNode <LibraryDescription> >( node: root, getChildren: node => { if (node.Resolved) { return node.Dependencies.Select(dependency => dependency.Library); } else { return Enumerable.Empty <LibraryDescription>(); } }, visitNode: (node, children) => { return new GraphNode <LibraryDescription>(node, children); })); }
public static IGraphNode<LibraryDependency> Build( IEnumerable<LibraryDescription> libraries, Runtime.Project project) { if (libraries == null) { throw new ArgumentNullException(nameof(libraries)); } if (project == null) { throw new ArgumentNullException(nameof(project)); } var root = new LibraryDependency { Library = libraries.FirstOrDefault(p => string.Equals(p.Identity.Name, project.Name)), LibraryRange = null }; if (root.Library == null) { throw new InvalidOperationException($"Failed to retrieve {nameof(LibraryDependency)} of project {project.Name}/{project.Version}"); } // build a tree of LibraryDescriptions of the given project root return DepthFirstGraphTraversal.PostOrderWalk<LibraryDependency, IGraphNode<LibraryDependency>>( node: root, getChildren: node => { if (node.Library.Resolved) { return node.Library.Dependencies; } else { return Enumerable.Empty<LibraryDependency>(); } }, visitNode: (node, children) => { return new GraphNode<LibraryDependency>(node, children); }); }
public IGraphNode <Library> Build(Library root) { return(DepthFirstGraphTraversal.PostOrderWalk <Library, IGraphNode <Library> >( node: root, getChildren: node => { LibraryDescription desc; if (_libDictionary.TryGetValue(node, out desc)) { return desc.Dependencies.Select(dep => dep.Library); } else { return Enumerable.Empty <Library>(); } }, visitNode: (node, children) => { return new GraphNode <Library>(node, children); })); }