public static string GetPropertyNameByMethod(MethodDefinition method) { if (!method.IsPropertyMethod()) throw new ArgumentException("Not a property method", "method"); return method.Name.Substring (4); }
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 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); }