/// <summary>
 /// 当文档碎片被分配到文档上时被调用,用于释放碎片。
 /// </summary>
 /// <param name="fragment"></param>
 internal void Allocated(DomFragment fragment)
 {
     lock ( SyncRoot )
     {
         _fragments.Remove(fragment);
     }
 }
Example #2
0
            /// <summary>
            /// 解析 HTML 文本到指定的文档碎片对象
            /// </summary>
            /// <param name="html"></param>
            /// <param name="fragment"></param>
            public virtual void ProcessFragment(string html, DomFragment fragment)
            {
                if (string.IsNullOrEmpty(html))
                {
                    return;
                }

                lock ( SyncRoot )
                {
                    InitializeStack();

                    ContainerStack.Push(fragment);

                    ParseInternal(html);

                    fragment.ContentFragment = new HtmlContentFragment(Reader, 0, Reader.HtmlText.Length);
                }
            }
Example #3
0
        /// <summary>
        /// 解析 HTML 文本到指定的文档碎片对象
        /// </summary>
        /// <param name="html">要解析的 HTML 文本</param>
        /// <param name="fragment">要处理的文本碎片</param>
        public virtual void ParseToFragment(string html, DomFragment fragment)
        {
            if (string.IsNullOrEmpty(html))
            {
                return;
            }

            lock ( SyncRoot )
            {
                Initialize();

                SetHtmlSpecification(fragment.Document.HtmlSpecification);

                ContainerStack.Push(fragment);

                ParseInternal(html);

                fragment.ContentFragment = new HtmlContentFragment(Reader, 0, Reader.HtmlText.Length);
            }
        }
Example #4
0
 internal void OnFragmentInto( DomFragment fragment, IHtmlContainer targetContainer, DomNode node )
 {
   OnDomChanged( this, new HtmlDomChangedEventArgs( node, fragment, HtmlDomChangedAction.Remove ) );
   OnDomChanged( this, new HtmlDomChangedEventArgs( node, targetContainer, HtmlDomChangedAction.Add ) );
 }
Example #5
0
    /// <summary>
    /// 解析 HTML 文本到指定的文档碎片对象
    /// </summary>
    /// <param name="html">要解析的 HTML 文本</param>
    /// <param name="fragment">要处理的文本碎片</param>
    public virtual void ParseToFragment( string html, DomFragment fragment )
    {

      if ( string.IsNullOrEmpty( html ) )
        return;

      lock ( SyncRoot )
      {

        Initialize();

        SetHtmlSpecification( fragment.Document.HtmlSpecification );

        ContainerStack.Push( fragment );

        ParseInternal( html );

        fragment.ContentFragment = new HtmlContentFragment( Reader, 0, Reader.HtmlText.Length );
      }
    }
Example #6
0
 internal void OnFragmentInto(DomFragment fragment, IHtmlContainer targetContainer, DomNode node)
 {
     OnDomChanged(this, new HtmlDomChangedEventArgs(node, fragment, HtmlDomChangedAction.Remove));
     OnDomChanged(this, new HtmlDomChangedEventArgs(node, targetContainer, HtmlDomChangedAction.Add));
 }
Example #7
0
 /// <summary>
 /// 当文档碎片被分配到文档上时被调用,用于释放碎片。
 /// </summary>
 /// <param name="fragment"></param>
 internal void Allocated( DomFragment fragment )
 {
   lock ( SyncRoot )
   {
     _fragments.Remove( fragment );
   }
 }