【问题标题】:PostSharp - How to inject a method into a class?PostSharp - 如何将方法注入到类中?
【发布时间】: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

【问题讨论】:

    标签: postsharp code-injection


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    • 2023-03-19
    • 2017-08-26
    • 1970-01-01
    相关资源
    最近更新 更多