本文整理汇总了C#中IHtmlElement.Require方法的典型用法代码示例。如果您正苦于以下问题:C# IHtmlElement.Require方法的具体用法?C# IHtmlElement.Require怎么用?C# IHtmlElement.Require使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHtmlElement
的用法示例。
在下文中一共展示了IHtmlElement.Require方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEmbeddingTR
/// <summary>
/// Returns the TR element embedding the given element.
/// If the given element itself is a TR, this one is returned.
/// </summary>
public static IHtmlElement GetEmbeddingTR( IHtmlElement e )
{
e.Require( x => e != null );
if ( e.TagName == "TR" )
{
return e;
}
else
{
var parent = e.FindParent( p => p.TagName == "TR", p => e.IsTableOrTBody() );
return (parent == null ? null : parent);
}
}
示例2: GetRow
/// <summary>
/// Gets the complete row of the given cell.
/// </summary>
public static IEnumerable<IHtmlElement> GetRow( IHtmlElement cell )
{
cell.Require( x => cell != null );
var row = GetEmbeddingTR( cell );
if ( row == null )
{
throw new ArgumentException( "Element does not point to cell inside table row" );
}
return row.Children;
}
示例3: GetColumn
/// <summary>
/// Gets the complete column of the given cell.
/// <remarks>Attention: Handling "colspan" is not implemented.
/// A TR without any TD is skipped.</remarks>
/// </summary>
public static IEnumerable<IHtmlElement> GetColumn( IHtmlElement cell )
{
cell.Require( x => cell != null );
HtmlTable table = cell.FindEmbeddingTable();
if ( table == null )
{
throw new ArgumentException( "Element does not point to into table" );
}
int colIdx = cell.GetChildPos();
foreach ( object row in table.TableBody.Children )
{
IHtmlElement e = ((IHtmlElement)row).GetChildAt( "TD", colIdx );
if ( e == null )
{
continue;
}
yield return e;
}
}