Bloom.Book.HtmlDom.SortStyleSheetLinks C# (CSharp) Method

SortStyleSheetLinks() public method

public SortStyleSheetLinks ( ) : void
return void
        public void SortStyleSheetLinks()
        {
            List<XmlElement> links = new List<XmlElement>();
            foreach(XmlElement link in SafeSelectNodes("//link[@rel='stylesheet']"))
            {
                links.Add(link);
            }
            if(links.Count < 2)
                return;

            var headNode = links[0].ParentNode;

            //clear them out
            foreach(var xmlElement in links)
            {
                headNode.RemoveChild(xmlElement);
            }

            links.Sort(new StyleSheetLinkSorter());

            //add them back
            foreach(var xmlElement in links)
            {
                headNode.AppendChild(xmlElement);
            }
        }

Usage Example

Example #1
0
 //while in Bloom, we could have and edit style sheet or (someday) other modes. But when stored,
 //we want to make sure it's ready to be opened in a browser.
 private void MakeCssLinksAppropriateForStoredFile(HtmlDom dom)
 {
     dom.RemoveModeStyleSheets();
     dom.AddStyleSheet("previewMode.css");
     dom.AddStyleSheet("basePage.css");
     EnsureHasLinksToStylesheets(dom);
     dom.SortStyleSheetLinks();
     dom.RemoveFileProtocolFromStyleSheetLinks();
 }
All Usage Examples Of Bloom.Book.HtmlDom::SortStyleSheetLinks