Пример #1
0
        /// <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);
        }
Пример #2
0
    /// <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 );
    }