標籤:style blog http io ar os 使用 sp for
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 weight Can only be used on interfaces or MarshalByRefObjects 微顯重量級 僅在介面或 MarshalByRefObjects 上使用 |
Deriving from ContextBoundObject 從 ContextBoundObject 派生 |
Easiest to implement Native 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 understand Very 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 powerful Good performance 非常強大 良好的效能 |
Very hard to implement 實現非常困難 |
Runtime IL-weaving ( Post Sharp / Cecil ) 運行時 IL 織入 |
Very powerful Good performance 非常強大 朗好的效能 |
Very hard to implement 實現非常困難 |
文獻來源:http://ayende.com/blog/2615/7-approaches-for-aop-in-net
AOP在 .NET中的七種實現方法