// MetaAspect Eval /// Some definitions may have been added from outside (typically for embedded advice) /// Just add the new definitions the expressions point to private void Eval(AdviceSpec spec, string XPathBase, string XPathConstraint) { // Evaluate the XPath expressions on Cecil object model if (spec.targetXPath != null) { spec.TargetNavigators.AddRange(Cil.TargetNavigator.SelectList(spec.targetXPath + XPathConstraint)); } else if (spec.targetRegExp != null) { foreach (Navigator nav in Cil.TargetNavigator.SelectList(XPathBase + XPathConstraint)) { if (SimpleRegex.IsPreciseMatch(nav, spec.targetRegExp)) { spec.TargetNavigators.Add(nav); } } } if (spec.aspectXPath != null) { spec.AspectNavigators.AddRange(Cil.AspectsNavigator.SelectList(spec.aspectXPath)); } else if (spec.aspectRegExp != null) { foreach (Navigator nav in Cil.AspectsNavigator.SelectList(Cil.AllDeclarations)) { if (SimpleRegex.IsPreciseMatch(nav, spec.aspectRegExp)) { spec.AspectNavigators.Add(nav); } } } }
private static void TestSimpleRegex() { string txt = "some some .text"; AssertTrue(SimpleRegex.IsPreciseMatch(txt, "so*xt")); AssertFalse(SimpleRegex.IsPreciseMatch(txt, "so*.ext")); AssertFalse(SimpleRegex.IsPreciseMatch(txt, "{some }2.text")); }