Пример #1
0
 public static void Help(InstallTree tree, string [] args)
 {
     Console.Write("Commands are ");
     foreach (var function in functions)
     {
         Console.Write(function.Key + " ");
     }
 }
Пример #2
0
 public static void PrintNodes(InstallTree tree, string [] args)
 {
     Console.WriteLine("Printing all Nodes");
     foreach (var node in tree.Nodes)
     {
         Console.WriteLine(node.Value.Name);
     }
 }
Пример #3
0
        public static void UnInstall(InstallTree tree, string[] arg)
        {
            Console.WriteLine("UnInstalling " + arg[0]);
            var result = InstallMethods.UnInstallNodeInTree(tree, arg[0]);

            if (result.Success)
            {
                Console.WriteLine("UnInstall Successful");
            }
            else
            {
                Console.WriteLine("UnInstall Unsuccessful");
            }
        }
Пример #4
0
        public static void Depend(InstallTree tree, string [] args)
        {
            Console.WriteLine("Adding " + args[0]);
            Console.WriteLine("Depending on " + String.Join(", ", args.Skip(1).ToArray()));
            var node     = new InstallNode(args[0]);
            var response = InstallMethods.AddNode(tree, args[0], args.Skip(1).ToList());

            if (response.Success)
            {
                Console.WriteLine("Dependency addition Successful");
            }
            else
            {
                Console.WriteLine("Dependency addition Failed");
            }
        }
Пример #5
0
        public static InstallResponse InstallNodeInTree(InstallTree tree, string Name)
        {
            if (!tree.Nodes.ContainsKey(Name))
            {
                return(new InstallResponse()
                {
                    Tree = tree,
                    Success = false
                });
            }
            ;
            var node = tree.Nodes[Name];

            InstallNode(node);
            return(new InstallResponse()
            {
                Tree = tree, Success = true
            });
        }
Пример #6
0
        public static InstallResponse UnInstallNodeInTree(InstallTree tree, string Name)
        {
            Console.WriteLine("Attempting to uninstall " + Name);
            if (!tree.Nodes.ContainsKey(Name))
            {
                return(new InstallResponse()
                {
                    Tree = tree,
                    Success = false
                });
            }
            ;

            UnInstallNode(tree.Nodes[Name]);
            return(new InstallResponse()
            {
                Tree = tree, Success = true
            });
        }
Пример #7
0
        public static InstallResponse AddDepends(InstallTree tree, InstallNode addNode, List <String> DependsOn)
        {
            if (DependsOn == null)
            {
                return new InstallResponse()
                       {
                           Success = true, Tree = tree
                       }
            }
            ;
            foreach (var depends in DependsOn)
            {
                InstallNode n = null;

                if (tree.Nodes.ContainsKey(depends))
                {
                    n = tree.Nodes[depends];
                }
                else
                {
                    n = new InstallNode(depends);
                    tree.Nodes[depends] = n;
                }

                addNode.DependsOn.Add(n);
                if (DetectDepends(n, addNode))
                {
                    return(new InstallResponse()
                    {
                        Success = false, Tree = tree
                    });
                }
                ;
                n.Dependents.Add(addNode);
            }
            tree.Nodes[addNode.Name] = addNode;

            return(new InstallResponse()
            {
                Success = true, Tree = tree
            });
        }
Пример #8
0
        public static InstallResponse AddNode(InstallTree Tree, string Name, List <String> DependsOn)
        {
            if (Tree == null)
            {
                return(new InstallResponse()
                {
                    Tree = new InstallTree(), Success = false
                });
            }
            var response = new InstallResponse();

            InstallNode addNode = null;

            if (!Tree.Nodes.TryGetValue(Name, out addNode))
            {
                Tree.Nodes[Name] = addNode = new InstallNode(Name);
            }

            response.Tree = Tree;

            var depResp = AddDepends(Tree, addNode, DependsOn);

            return(depResp);
        }
Пример #9
0
 public static void Clear(InstallTree tree, string [] arg)
 {
     Console.WriteLine("Clearing Install Tree");
     tree = new InstallTree();
 }