/// <summary> /// 将 HTML 注释添加到指定容器的末尾。 /// </summary> /// <param name="comment">要添加的 HTML 注释</param> /// <param name="container">被添加的容器</param> /// <returns>添加后的 HTML 注释</returns> public static IHtmlComment AppendTo(this IFreeComment comment, IHtmlContainer container) { if (comment == null) { throw new ArgumentNullException("comment"); } if (container == null) { throw new ArgumentNullException("container"); } return(comment.InsertTo(container, container.Nodes().Count())); }
/// <summary> /// 将 HTML 注释插入到指定位置。 /// </summary> /// <param name="comment">要插入的 HTML 注释</param> /// <param name="container">被插入的容器</param> /// <param name="index">插入的位置</param> /// <returns>插入后的 HTML 注释</returns> public static IHtmlComment InsertTo(this IFreeComment comment, IHtmlContainer container, int index) { if (comment == null) { throw new ArgumentNullException("comment"); } if (container == null) { throw new ArgumentNullException("container"); } lock (container.SyncRoot) { if (!container.Document.Equals(comment.Document)) { throw new InvalidOperationException(); } return((IHtmlComment)comment.Into(container, index)); } }