Exemple #1
0
        public void AddChild(TreeNode node)
        {
            if (node == null)
                throw new System.ArgumentNullException("Node cannot be null.");

            children.Add(node);

            foreach (TreeNode child in children)
                child.AddParent(this);
        }
Exemple #2
0
 private void AddParent(TreeNode node)
 {
     parent.Add(node);
 }
Exemple #3
0
        /// <summary>
        /// Adds the driver to the driverHash and to the equivalence tree.
        /// </summary>
        /// <param name="driver">Object representing the interface of the Driver to be added</param>
        public void AddToEquivalenceTree(UpDriver driver)
        {
            TreeNode node = new TreeNode(driver);
            List<string> equivalentDrivers = driver.equivalentDrivers;
            HashSet<string> driversNotFound = new HashSet<string>();

            if (equivalentDrivers != null)
            {
                foreach (string equivalentDriver in equivalentDrivers)
                {
                    TreeNode parent = null;
                    if (!driverHash.TryGetValue(equivalentDriver, out parent))
                        driversNotFound.Add(equivalentDriver);
                    else
                    {
                        ValidateInterfaces(parent.driver.services, node.driver.services);
                        ValidateInterfaces(parent.driver.events, node.driver.events);
                        parent.AddChild(node);
                    }
                }
            }
            else
                tree.Add(node);

            if (driversNotFound.Count > 0)
                throw new DriverNotFoundException("Equivalent drivers not found.", driversNotFound);

            driverHash[driver.name] = node;
        }