Beispiel #1
0
        void PrintPackage(TreeRenderer tree, Package package)
        {
            var packageName = package.PackageInfo.Name + " " + package.PackageInfo.Version;

            if (package.PackageInfo.Title != null)
            {
                packageName += " (" + package.PackageInfo.Title + ")";
            }
            if (package.Locked)
            {
                packageName += " [locked]";
            }
            var dependsLine = "depends: " + package.Spec;

            tree.PrintLine(IncludeDependencies ? dependsLine : packageName);

            var childNodes = package.Children == Truncated
                                 ? new[] { new Node <string>("...", (t, val) => t.PrintLine(val)) }
                                 : package.Children.Select(_ => new Node <Package>(_, PrintPackage)).Cast <Node>();

            if (!IncludeDependencies)
            {
                childNodes.Render(tree);
            }
            else
            {
                new[] { new Node <string>(packageName,
                                          (t, val) =>
                    {
                        t.PrintLine(val);
                        childNodes.Render(t);
                    }) }.Render(tree);
            }
        }
Beispiel #2
0
        public override string ToString()
        {
            var tree = new TreeRenderer();

            tree.PrintLine("─" + DescriptorName);
            PrintPackages(tree);

            return(tree.Content);
        }
Beispiel #3
0
 public override void Render(TreeRenderer tree)
 {
     _renderer(tree, _value);
 }
Beispiel #4
0
 public static void Render(this IEnumerable <Node> nodes, TreeRenderer renderer)
 {
     renderer.PrintChildren(nodes, node => node.Render(renderer));
 }
Beispiel #5
0
 public abstract void Render(TreeRenderer tree);
Beispiel #6
0
 void PrintPackages(TreeRenderer tree)
 {
     Packages.Select(_ => new Node <Package>(_, PrintPackage))
     .Cast <Node>()
     .Render(tree);
 }