/// <summary> /// 创建注释的副本 /// </summary> /// <param name="factory">用于创建注释的构建器</param> /// <param name="comment">需要被创建副本的注释</param> /// <returns>注释的未分配副本</returns> public static IFreeComment MakeCopy(this IHtmlNodeFactory factory, IHtmlComment comment) { if (factory == null) { throw new ArgumentNullException("factory"); } if (comment == null) { throw new ArgumentNullException("comment"); } return(factory.CreateComment(comment.Comment)); }
/// <summary> /// 添加注释节点的副本 /// </summary> /// <param name="container">要添加副本的容器</param> /// <param name="index">要添加的位置</param> /// <param name="comment">要创作副本的注释节点</param> /// <returns>添加后的注释节点</returns> public static IHtmlComment AddCopy(this IHtmlContainer container, int index, IHtmlComment comment) { if (container == null) { throw new ArgumentNullException("container"); } if (comment == null) { throw new ArgumentNullException("comment"); } return(container.AddComment(index, comment.Comment)); }
/// <summary> /// 添加注释节点的副本 /// </summary> /// <param name="container">要添加副本的容器</param> /// <param name="comment">要创作副本的注释节点</param> /// <returns>添加后的注释节点</returns> public static IHtmlComment AddCopy(this IHtmlContainer container, IHtmlComment comment) { if (container == null) { throw new ArgumentNullException("container"); } if (comment == null) { throw new ArgumentNullException("comment"); } lock (container.SyncRoot) { return(AddCopy(container, container.Nodes().Count(), comment)); } }
/// <summary> /// 在前面添加节点的副本 /// </summary> /// <param name="node">要在其前面添加副本的节点</param> /// <param name="comment">要创作副本的节点</param> /// <returns>添加后的节点</returns> public static IHtmlComment AddCopyBeforeSelf(this IHtmlNode node, IHtmlComment comment) { if (node == null) { throw new ArgumentNullException("node"); } if (comment == null) { throw new ArgumentNullException("comment"); } var container = node.Container; lock (container.SyncRoot) { return(container.AddCopy(node.NodesIndexOfSelf(), comment)); } }
/// <summary> /// 在前面添加节点的副本 /// </summary> /// <param name="node">要在其前面添加副本的节点</param> /// <param name="comment">要创作副本的节点</param> /// <returns>添加后的节点</returns> public static IHtmlComment AddCopyBeforeSelf( this IHtmlNode node, IHtmlComment comment ) { if ( node == null ) throw new ArgumentNullException( "node" ); if ( comment == null ) throw new ArgumentNullException( "comment" ); var container = node.Container; lock ( container.SyncRoot ) { return container.AddCopy( node.NodesIndexOfSelf(), comment ); } }