Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有一个 MethodInterceptionAspect,我该如何定义它以包括它正在拦截的类中的所有方法,但构造函数除外?
例如,以下几行似乎不起作用...
[MyAspect(AttributeTargetMembers="regex:!.cctor|.*")]
您需要将您的属性应用于带有AttributeTargetElements = MulticastTargets.Method. 它针对方法(但不是构造函数)。
AttributeTargetElements = MulticastTargets.Method
这应该可以解决问题:
[MyAspect(AttributeTargetElements = MulticastTargets.Method)]