示例#1
0
文件: HtmlNode.cs 项目: ttrr1/Midea
        public HtmlNode CloneNode(bool deep)
        {
            HtmlNode node = this._ownerdocument.CreateNode(this._nodetype);

            node._name = this.Name;
            switch (this._nodetype)
            {
            case HtmlNodeType.Comment:
                ((HtmlCommentNode)node).Comment = ((HtmlCommentNode)this).Comment;
                return(node);

            case HtmlNodeType.Text:
                ((HtmlTextNode)node).Text = ((HtmlTextNode)this).Text;
                return(node);
            }
            if (this.HasAttributes)
            {
                using (HtmlAttributeCollection.HtmlAttributeEnumerator enumerator = this._attributes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        HtmlAttribute newAttribute = enumerator.Current.Clone();
                        node.Attributes.Append(newAttribute);
                    }
                }
            }
            if (this.HasClosingAttributes)
            {
                node._endnode = this._endnode.CloneNode(false);
                using (HtmlAttributeCollection.HtmlAttributeEnumerator enumerator2 = this._endnode._attributes.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        HtmlAttribute attribute4 = enumerator2.Current.Clone();
                        node._endnode._attributes.Append(attribute4);
                    }
                }
            }
            if (deep)
            {
                if (!this.HasChildNodes)
                {
                    return(node);
                }
                using (HtmlNodeCollection.HtmlNodeEnumerator enumerator3 = this._childnodes.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        HtmlNode newChild = enumerator3.Current.Clone();
                        node.AppendChild(newChild);
                    }
                }
            }
            return(node);
        }
示例#2
0
文件: HtmlNode.cs 项目: ttrr1/Midea
 public void WriteContentTo(TextWriter outText)
 {
     if (this._childnodes != null)
     {
         using (HtmlNodeCollection.HtmlNodeEnumerator enumerator = this._childnodes.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 enumerator.Current.WriteTo(outText);
             }
         }
     }
 }