internal void MoveChildrenTo(ParentElementBuilder anotherParent)
        {
            // When we move the children, that will cause all our ChildOrderings to be removed.  So we'll maintain a temporary reference to them.
            HashSet <ChildOrdering> orderings = ChildOrderings;

            ChildrenAndRoles.ToList().ForEach(kvp => kvp.Key.MoveTo(anotherParent, kvp.Value));
            anotherParent.ChildOrderings = orderings;
        }
        /// <summary>Make a lightweight copy of the children in <paramref name="anotherParent"/>, and add the copied children to this ParentElementBuilder.</summary>
        /// <returns>this</returns>
        internal ParentElementBuilder LightweightCopyChildrenFrom(ParentElementBuilder anotherParent)
        {
            // Create a copy of each child and put the copies in a Dictionary so they can be looked up using the original child as a key
            Dictionary <IElementTreeNode, IElementTreeNode> copiedChildren = new Dictionary <IElementTreeNode, IElementTreeNode>();

            foreach (KeyValuePair <IElementTreeNode, ChildRole> eachChildAndRole in anotherParent.ChildrenAndRoles)
            {
                IElementTreeNode copiedChild = eachChildAndRole.Key.CopyLightweight();
                AddChildWithRole(copiedChild, eachChildAndRole.Value);
                copiedChildren.Add(eachChildAndRole.Key, copiedChild);
            }
            // Create copies of the ChildOrderings that refer to the copied children
            foreach (ChildOrdering eachOrdering in anotherParent.ChildOrderings)
            {
                ChildOrderings.Add(new ChildOrdering
                {
                    Before = copiedChildren[eachOrdering.Before],
                    After  = copiedChildren[eachOrdering.After]
                });
            }
            return(this);
        }
 internal Enumerator(ParentElementBuilder parent)
 {
     Builder    = parent;
     Components = Builder.Children.Select(child => child.GetVariationsEnumerator()).ToList();
     Reset();
 }
 internal Variations(ParentElementBuilder parent) => Builder = parent;
Exemple #5
0
 /// <summary>Return true if this is a direct child of <paramref name="prospectiveParent"/>.</summary>
 public bool IsChildOf(ParentElementBuilder prospectiveParent) => prospectiveParent.Children.Contains(this);