本文整理汇总了C#中IHtmlElement.Parent方法的典型用法代码示例。如果您正苦于以下问题:C# IHtmlElement.Parent方法的具体用法?C# IHtmlElement.Parent怎么用?C# IHtmlElement.Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHtmlElement
的用法示例。
在下文中一共展示了IHtmlElement.Parent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsEligible
protected override bool IsEligible( ISelector leftSelector, IHtmlElement element )
{
var restrict = leftSelector as ContainerRestrict;
if ( restrict != null )
return restrict.RestrictContainer.Nodes().Contains( element );
return leftSelector.IsEligibleBuffered( element.Parent() );
}
示例2: CreateIdentity
private static string CreateIdentity( IHtmlElement element, bool ancestorsCreate )
{
string parentId;
var parentElement = element.Parent();
if ( parentElement != null )
{
parentId = Identity( parentElement );
if ( parentId == null )
{
if ( ancestorsCreate )
parentId = Identity( parentElement, true, true );
else
parentId = CreateIdentity( parentElement, false );
}
}
else
{
if ( element.Container is IHtmlDocument )
parentId = null;
else
throw new InvalidOperationException();
}
var name = GetElementName( element );
var builder = new StringBuilder();
if ( !string.IsNullOrEmpty( parentId ) )
builder.AppendFormat( "{0}_", parentId );
builder.Append( name );
string identity;
if ( element.Siblings().Where( e => GetElementName( e ).EqualsIgnoreCase( GetElementName( element ) ) ).IsSingle() )
identity = builder.ToString();
var index = element.SiblingsBeforeSelf().Count( e => GetElementName( e ).EqualsIgnoreCase( GetElementName( element ) ) );
builder.Append( index + 1 );
identity = builder.ToString();
return EnsureUniqueness( identity, element.Document );
}
示例3: IsEligible
protected override bool IsEligible( ISelector leftSelector, IHtmlElement element )
{
var restrict = leftSelector as ContainerRestrict;
if ( restrict != null )
return element.IsDescendantOf( restrict.RestrictContainer );
var parant = element.Parent();
//如果父级元素符合左选择器,或者父级元素符合本选择器。
return leftSelector.IsEligibleBuffered( parant ) || this.IsEligibleBuffered( parant );
}