private static bool IsApplicableElementTarget(AspectDeclaration aspect, MethodDefinition method) { var elemetTargets = aspect.ElementTargets; if (elemetTargets == ElementTargets.Default) { return(true); } bool isCCtor = method.IsStatic && method.IsConstructor; bool isCtor = !method.IsStatic && method.IsConstructor; bool isProperty = method.IsPropertyMethod(); if ((elemetTargets & ElementTargets.StaticConstructor) == ElementTargets.StaticConstructor && isCCtor) { return(true); } if ((elemetTargets & ElementTargets.InstanceConstructor) == ElementTargets.InstanceConstructor && isCtor) { return(true); } if ((elemetTargets & ElementTargets.Property) == ElementTargets.Property && isProperty) { return(true); } if ((elemetTargets & ElementTargets.Method) == ElementTargets.Method && !(isCtor || isCCtor || isProperty)) { return(true); } return(false); }
private static bool IsApplicableTypeTarget(AspectDeclaration aspect, MethodDefinition method) { if (String.IsNullOrEmpty(aspect.TypeTargets)) { return(true); } var re = BuildRegexFromSearchPattern(aspect.TypeTargets); bool searchInFullName = (re.ToString().Contains(@"\.") || re.ToString().Contains(@"/")); string typeName = searchInFullName ? method.DeclaringType.FullName : method.DeclaringType.Name; return(re.IsMatch(typeName)); }
private static bool IsApplicableMemberTarget(AspectDeclaration aspect, MethodDefinition method) { if (String.IsNullOrEmpty(aspect.MemberTargets)) { return(true); } var re = BuildRegexFromSearchPattern(aspect.MemberTargets); if (method.IsPropertyMethod()) { return(re.IsMatch(method.Name) || re.IsMatch(TypeTools.GetPropertyNameByMethod(method))); } return(re.IsMatch(method.Name)); }