/// <summary> /// 添加所有资源引用 /// </summary> /// <param name="document"></param> /// <param name="clearReferenceFirst"></param> public void AddAllReference(IHtmlDocument document, bool clearReferenceFirst = true) { if (document == null) { return; } if (clearReferenceFirst) { ClearAllReference(document); } var headElement = document.FindFirstOrDefault("head"); if (headElement == null) { var firstElement = document.Elements().FirstOrDefault(); if (firstElement != null) { headElement = firstElement.AddElementBeforeSelf("head"); } else { headElement = document.AddElement(0, "head"); } } AddStyleReferences(headElement, styleFiles); AddScriptReferences(headElement, scriptFiles); }
/// <summary> /// 添加所有资源引用 /// </summary> /// <param name="document"></param> /// <param name="clearReferenceFirst"></param> public void AddAllReference( IHtmlDocument document, bool clearReferenceFirst = true ) { if ( document == null ) return; if ( clearReferenceFirst ) ClearAllReference( document ); var headElement = document.FindFirstOrDefault( "head" ); if ( headElement == null ) { var firstElement = document.Elements().FirstOrDefault(); if ( firstElement != null ) headElement = firstElement.AddElementBeforeSelf( "head" ); else headElement = document.AddElement( 0, "head" ); } AddStyleReferences( headElement, styleFiles ); AddScriptReferences( headElement, scriptFiles ); }