Exemple #1
0
        private void Merge(IBuildTreeNode tree, IBuildTreeNode path)
        {
            var target = tree.Children.FirstOrDefault(c => c == path);

            if (target == null)
            {
                tree.AddChild(path);
            }
            else
            {
                foreach (var child in path.Children)
                {
                    Merge(target, child);
                }
            }
        }
Exemple #2
0
        private void Merge(IBuildTreeNode tree, IBuildTreeNode nodeToInsert, List <IBuildTreeNode> taggedNodes)
        {
            var insertTarget = tree;

            var subTree = insertTarget.Children.FirstOrDefault(node => node.Equals(nodeToInsert));

            if (subTree != null)
            {
                subTree.UpdateWithValuesFrom(nodeToInsert);

                if (nodeToInsert.Children.Any())
                {
                    Merge(subTree, nodeToInsert.Children.First(), taggedNodes);
                }

                taggedNodes.Remove(subTree);
            }
            else
            {
                tree.AddChild(nodeToInsert);
                taggedNodes.Remove(tree);
            }
        }