Bloom.Book.BookStarter.SetupIdAndLineage C# (CSharp) Method

SetupIdAndLineage() public static method

public static SetupIdAndLineage ( XmlElement parentPageDiv, XmlElement childPageDiv ) : void
parentPageDiv System.Xml.XmlElement
childPageDiv System.Xml.XmlElement
return void
        public static void SetupIdAndLineage(XmlElement parentPageDiv, XmlElement childPageDiv)
        {
            //NB: this works even if the parent and child are the same, which is the case when making a new book
            //but not when we're adding an individual template page. (Later: Huh?)

            childPageDiv.SetAttribute("id", Guid.NewGuid().ToString());

            if (parentPageDiv != null) //until we get the xmatter also coming in, xmatter pages will have no parentDiv available
            {
                string parentId = parentPageDiv.GetAttribute("id");
                string parentLineage = parentPageDiv.GetOptionalStringAttribute("data-pagelineage", string.Empty);
                childPageDiv.SetAttribute("data-pagelineage", (parentLineage + ";" + parentId).Trim(new char[] {';'}));
            }
        }