当前位置: 首页>>代码示例>>C#>>正文


C# IdentifierExpression.IsMatch方法代码示例

本文整理汇总了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;
 }
开发者ID:dineshkummarc,项目名称:SWAT_4.1_Binaries_Source,代码行数:20,代码来源:InternetExplorer.cs

示例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;
            }
        }
开发者ID:dineshkummarc,项目名称:SWAT_4.1_Binaries_Source,代码行数:85,代码来源:FireFox.cs


注:本文中的IdentifierExpression.IsMatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。