AngleSharp by Florian Rappl

<PackageReference Include="AngleSharp" Version="0.8.0" />

.NET API 1,171,968 bytes

 HtmlTableRowElement

Represents the HTML tr element.
using AngleSharp.Dom.Collections; using AngleSharp.Dom.Css; using AngleSharp.Extensions; using AngleSharp.Html; using AngleSharp.Linq; namespace AngleSharp.Dom.Html { internal sealed class HtmlTableRowElement : HtmlElement, IHtmlTableRowElement, IHtmlElement, IElement, INode, IEventTarget, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle { private readonly HtmlCollection<HtmlTableCellElement> _cells; public HorizontalAlignment Align { get { return GetAttribute(AttributeNames.Align).ToEnum(HorizontalAlignment.Left); } set { SetAttribute(AttributeNames.Align, value.ToString()); } } public VerticalAlignment VAlign { get { return GetAttribute(AttributeNames.Valign).ToEnum(VerticalAlignment.Middle); } set { SetAttribute(AttributeNames.Valign, value.ToString()); } } public string BgColor { get { return GetAttribute(AttributeNames.BgColor); } set { SetAttribute(AttributeNames.BgColor, value); } } public IHtmlCollection Cells => _cells; public int Index { get { IElement parentElement = base.ParentElement; while (parentElement != null && !(parentElement is HtmlTableElement)) { parentElement = parentElement.ParentElement; } IHtmlTableElement htmlTableElement = parentElement as IHtmlTableElement; if (htmlTableElement != null) return htmlTableElement.Rows.Index(this); return 0; } } public int IndexInSection { get { IElement parentElement = base.ParentElement; while (parentElement != null && !(parentElement is IHtmlTableSectionElement)) { parentElement = parentElement.ParentElement; } IHtmlTableSectionElement htmlTableSectionElement = parentElement as IHtmlTableSectionElement; if (htmlTableSectionElement != null) return htmlTableSectionElement.Rows.Index(this); return 0; } } public HtmlTableRowElement(Document owner) : base(owner, Tags.Tr, NodeFlags.Special | NodeFlags.ImplicitelyClosed) { _cells = new HtmlCollection<HtmlTableCellElement>(this, true, null); } public IHtmlElement InsertCellAt(int index = -1) { HtmlTableCellElement htmlTableCellElement = _cells[index]; HtmlTableCellElement htmlTableCellElement2 = base.Owner.CreateElement(Tags.Td) as HtmlTableCellElement; if (htmlTableCellElement != null) InsertBefore(htmlTableCellElement2, htmlTableCellElement); else AppendChild(htmlTableCellElement2); return htmlTableCellElement2; } public void RemoveCellAt(int index) { if (index == -1) index = _cells.Length - 1; _cells[index]?.Remove(); } } }