示例#1
0
        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;
        }
示例#2
0
        /// <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);
        }
示例#3
0
 internal Enumerator(ParentElementBuilder parent)
 {
     Builder    = parent;
     Components = Builder.Children.Select(child => child.GetVariationsEnumerator()).ToList();
     Reset();
 }
示例#4
0
 internal Variations(ParentElementBuilder parent) => Builder = parent;
示例#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);