本文整理汇总了C#中IdentifierExpression.IsMatch方法的典型用法代码示例。如果您正苦于以下问题:C# IdentifierExpression.IsMatch方法的具体用法?C# IdentifierExpression.IsMatch怎么用?C# IdentifierExpression.IsMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdentifierExpression
的用法示例。
在下文中一共展示了IdentifierExpression.IsMatch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getElementByExp
private IHTMLElement getElementByExp(IdentifierExpression exp, IHTMLElementCollection elements)
{
foreach (IHTMLElement el in elements)
{
if (((bool)exp.IsMatch(el, BrowserType.InternetExplorer)))
return el;
else
{
//special case for the closing </li> tags
string tagCheck = exp._identifierExpression;
if (tagCheck.EndsWith("</li>"))
{
el.innerHTML = el.innerHTML.Replace("\r\n", "</li>");
if (((bool)exp.IsMatch(el, BrowserType.InternetExplorer)))
return el;
}
}
}
return null;
}
示例2: buildElementFindCommands
private void buildElementFindCommands(IdentifierType identType, string identifier, string elementTagName,
StringBuilder msg)
{
msg.Append("var elem = null;");
identifier = escapeChars(identifier);
string searchStr;
switch (identType)
{
case IdentifierType.Id:
buildElementFindCommands(IdentifierType.Expression, "id=" + identifier, elementTagName, msg);
break;
case IdentifierType.Name:
buildElementFindCommands(IdentifierType.Expression, "name=" + identifier, elementTagName, msg);
break;
case IdentifierType.InnerHtml:
searchStr =
string.Format(
"var elems = doc.getElementsByTagName('{0}'); for(var a=0;a < elems.length;a++){{ if(elems[a].innerHTML != null && elems[a].innerHTML.toString().toLowerCase() == '{1}')elem = elems[a];}}",
elementTagName, identifier.ToLower());
buildElementFindHelper(searchStr, msg);
break;
case IdentifierType.InnerHtmlContains:
searchStr =
string.Format(
"var elems = doc.getElementsByTagName('{0}'); for(var a=0;a < elems.length;a++){{ if(elems[a].innerHTML != null && elems[a].innerHTML.toString().toLowerCase().indexOf('{1}') > -1)elem = elems[a]; }}",
elementTagName, identifier.ToLower());
buildElementFindHelper(searchStr, msg);
break;
case IdentifierType.Expression:
string regularExpStmt;
StringBuilder completeRegularExp = new StringBuilder();
if (identifier.ToLower().Contains("style:"))
{
int styleInd = identifier.ToLower().IndexOf("style:");
if (styleInd > 0)
{
identifier = identifier.Remove(styleInd, 6).Insert(styleInd, "style:");
IdentifierExpression expPt1 =
new IdentifierExpression(
identifier.Substring(0, styleInd - (identifier[styleInd - 1] == ';' ? 1 : 0)),
IsMatchMethod);
completeRegularExp.Append("(");
completeRegularExp.Append((string) expPt1.IsMatch("", BrowserType.FireFox));
completeRegularExp.Append(")&&");
}
IdentifierExpression expPt2 = new IdentifierExpression(identifier.Substring(styleInd),
IsMatchMethod);
completeRegularExp.Append("(");
completeRegularExp.Append((string) expPt2.IsMatch("", BrowserType.FireFox));
completeRegularExp.Append(")");
//If there is a colon in the style string, meaning there are
//attribute-value pairs instead of seeking to match the entire style string
if (identifier.IndexOf(':', styleInd + 7) != -1)
{
//6 is the length of "style:"
completeRegularExp.Append("||(");
completeRegularExp.Append(buildStyleString(identifier.Substring(styleInd + 6)));
completeRegularExp.Append(")");
}
regularExpStmt = completeRegularExp.ToString();
}
else
{
IdentifierExpression exp = new IdentifierExpression(identifier, IsMatchMethod);
regularExpStmt = (string) exp.IsMatch("", BrowserType.FireFox);
}
searchStr =
string.Format(
"var elems = doc.getElementsByTagName('{0}'); for(a=0;a < elems.length;a++){{ if({1})elem = elems[a]; }}",
elementTagName, regularExpStmt);
buildElementFindHelper(searchStr, msg);
break;
}
}