7ApPRoaches for AOP in .Net
AOP在 .NET中的七種實(shí)現(xiàn)方法
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.
在這里列表了我想到的在你的應(yīng)用程序中加入AOP支持的所有方法。這里最主要的焦點(diǎn)是攔截,因?yàn)橐坏┯辛藬r截其它的事情都是細(xì)節(jié)。
Approach 方法 | Advantages 優(yōu)點(diǎn) | Disadvantages 缺點(diǎn) |
Remoting Proxies 遠(yuǎn)程代理 | Easy to implement, because of the .Net framework support 容易實(shí)現(xiàn),因?yàn)橛?NET 框架的支持。 | Somewhat heavy weightCan only be used on interfaces or MarshalByRefObjects 微顯重量級(jí) 僅在接口或 MarshalByRefObjects 上使用 |
Deriving from ContextBoundObject 從 ContextBoundObject 派生 | Easiest to implementNative support for call interception 很容易實(shí)現(xiàn) 原生支持調(diào)用攔截 | Very costly in terms of performance 非常昂貴的性能代價(jià) |
Compile-time subclassing( Rhino Proxy ) 編譯時(shí)子類化 | Easiest to understand 很容易理解 | Interfaces or virtual methods only 僅用于接口或虛方法 |
Runtime subclassing( Castle Dynamic Proxy ) 運(yùn)行時(shí)子類化 | Easiest to understandVery flexible 很容易理解 非常靈活 | Complex implementation (but already exists)Interfaces or virtual methods only 復(fù)雜的實(shí)現(xiàn)(已經(jīng)實(shí)現(xiàn)) 僅用于接口或虛方法 |
Hooking into the profiler API( Type Mock ) 分析 API 鉤子 | Extremely powerful 極端強(qiáng)大 | Performance?Complex implementation (COM API, require separate runner, etc) 性能未知 復(fù)雜實(shí)現(xiàn)(COM API,需要單獨(dú)運(yùn)行等) |
Compile time IL-weaving( Post Sharp / Cecil ) 編譯時(shí) IL 織入 | Very powerfulGood performance 非常強(qiáng)大 良好的性能 | Very hard to implement 實(shí)現(xiàn)非常困難 |
Runtime IL-weaving( Post Sharp / Cecil ) 運(yùn)行時(shí) IL 織入 | Very powerfulGood performance 非常強(qiáng)大 良好的性能 | Veryhard to implement 實(shí)現(xiàn)非常困難 |
文獻(xiàn)來(lái)源:http://ayende.com/blog/2615/7-approaches-for-aop-in-net
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注