1. 程式人生 > >.NET AOP(一)七種AOP實現方法

.NET AOP(一)七種AOP實現方法

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 sideof 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 heavyweight
Can only be used on interfaces or MarshalByRefObjects

微顯重量級

僅在介面或MarshalByRefObjects 上使用

Derivingfrom 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 alreadyexists)
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://www.cnblogs.com/tenghoo/archive/2010/12/22/aop.html#commentform點選開啟鏈