/// <summary> /// 在容器指定位置添加一个元素 /// </summary> /// <param name="container">要添加元素的容器</param> /// <param name="index">要添加元素的位置</param> /// <param name="name">添加元素的名称</param> /// <returns>添加好的元素</returns> public IHtmlElement AddElement(IHtmlContainer container, int index, string name) { lock ( _sync ) { unchecked { _version++; } var element = DomProvider.EnsureDomContainer(container).InsertNode(index, new DomElement(name, null)); OnDomChanged(this, new HtmlDomChangedEventArgs(element, container, HtmlDomChangedAction.Add)); return(element); } }
/// <summary> /// 在容器指定位置添加一个注释节点 /// </summary> /// <param name="container">要添加注释的容器</param> /// <param name="index">要添加注释的位置</param> /// <param name="name">添加注释的内容</param> /// <returns>添加好的注释节点</returns> public IHtmlComment AddComment(IHtmlContainer container, int index, string comment) { lock ( _sync ) { unchecked { _version++; } var commentNode = DomProvider.EnsureDomContainer(container).InsertNode(index, new DomComment(comment)); OnDomChanged(this, new HtmlDomChangedEventArgs(commentNode, container, HtmlDomChangedAction.Add)); return(commentNode); } }
/// <summary> /// 在容器指定位置添加一个特殊节点 /// </summary> /// <param name="container">要添加特殊节点的容器</param> /// <param name="index">要添加特殊节点的位置</param> /// <param name="name">添加特殊节点的 HTML</param> /// <returns>添加好的特殊节点</returns> public IHtmlSpecial AddSpecial(IHtmlContainer container, int index, string html) { lock ( _sync ) { unchecked { _version++; } var specialNode = DomProvider.EnsureDomContainer(container).InsertNode(index, new DomSpecial(html)); //UNDONE 未确定special node具体是什么 OnDomChanged(this, new HtmlDomChangedEventArgs(specialNode, container, HtmlDomChangedAction.Add)); return(specialNode); } }