【发布时间】:2011-12-01 17:03:54
【问题描述】:
我对 PostSharp 有一些问题(我假设其他库可以解决这个问题)。 我有这种情况:
我必须获取名称中包含单词的所有类,例如“Sth”。我的项目中有这些类(一个例子):
SthClass1.cs
SthClassBlabla.cs
SthClass3.cs
我发现这些类使用PostSharp:
[assembly: TraceAttribute( AttributeTargetMembers = "Sth*")]
那么,是否可以为每个找到的类注入(使用方面,PostSharp (?))代码?
示例:
SthClass1 myObj = new SthClass1();
myObj.ClassMethod1();
myObj.ClassMethod2();
myObj.InjectedMethod(); //that method belongs to the aspect
【问题讨论】: