public static MethodDefinition ConcreteMethodMatching(Navigator nav, string regex, AdviceSpec spec) { MethodDefinition result = Method(nav, spec); if (!SimpleRegex.IsMatch(result, regex)) { string errorMsg = string.Format ("Expected to match signature {0}, but got {1}", SimpleRegex.EscapePseudoRegex(regex), result); throw new AdviceException(errorMsg, spec); } return(result); }
public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { bool result = false; try { if (args.Length == 2) { XPathNodeIterator it = (XPathNodeIterator)args[0]; if (it.MoveNext()) { string pseudoRegexp = (string)args[1]; result = SimpleRegex.IsMatch(it.Current, pseudoRegexp); } } else { string pseudoRegexp = (string)args[0]; result = SimpleRegex.IsMatch(docContext, pseudoRegexp); } } catch (Exception e) { Console.WriteLine("Regular Expression function failed : \n" + e); } return(result); }