7ApPRoaches for AOP in .Net
AOP在 .NET中的七種實現方法
Here are all the ways that I can think of to add AOPto your application. This mostly focus on the interception side of things,because once you have that, everything else it just details.
在這里列表了我想到的在你的應用程序中加入AOP支持的所有方法。這里最主要的焦點是攔截,因為一旦有了攔截其它的事情都是細節。
Approach 方法 | Advantages 優點 | Disadvantages 缺點 |
Remoting Proxies 遠程代理 | Easy to implement, because of the .Net framework support 容易實現,因為有.NET 框架的支持。 | Somewhat heavy weightCan only be used on interfaces or MarshalByRefObjects 微顯重量級 僅在接口或 MarshalByRefObjects 上使用 |
Deriving from ContextBoundObject 從 ContextBoundObject 派生 | Easiest to implementNative support for call interception 很容易實現 原生支持調用攔截 | Very costly in terms of performance 非常昂貴的性能代價 |
Compile-time subclassing( Rhino Proxy ) 編譯時子類化 | Easiest to understand 很容易理解 | Interfaces or virtual methods only 僅用于接口或虛方法 |
Runtime subclassing( Castle Dynamic Proxy ) 運行時子類化 | Easiest to understandVery flexible 很容易理解 非常靈活 | Complex implementation (but already exists)Interfaces or virtual methods only 復雜的實現(已經實現) 僅用于接口或虛方法 |
Hooking into the profiler API( Type Mock ) 分析 API 鉤子 | Extremely powerful 極端強大 | Performance?Complex implementation (COM API, require separate runner, etc) 性能未知 復雜實現(COM API,需要單獨運行等) |
Compile time IL-weaving( Post Sharp / Cecil ) 編譯時 IL 織入 | Very powerfulGood performance 非常強大 良好的性能 | Very hard to implement 實現非常困難 |
Runtime IL-weaving( Post Sharp / Cecil ) 運行時 IL 織入 | Very powerfulGood performance 非常強大 良好的性能 | Veryhard to implement 實現非常困難 |
文獻來源:http://ayende.com/blog/2615/7-approaches-for-aop-in-net
新聞熱點
疑難解答