Dynamic Proxy

Castle Dynamic Proxy is a library for generating lightweitgh .NET Proxy on the fly at run time.    it worked as generating a subclass  of the given class and overried the virtual method at the run time.


    1. Cann't generate Proxy for sealed class

    2. Only virtual method can be intercepted.


Key Interface/Type:

  ProxyGenerator : used to generate the proxy

  IInterceptor:  add move behaviors here

  IInvocation: Holds all the infomation about the call

  IProxyTargetAccessor: each generated proxy implements IProxyTargetAccessor, we use it ( with method GetInterceptors()) to get the      interceptor we want

  ProxyGenerationOptions class: used to control how to generate the proxy. it accept a instance of IProxyGenerationHook to enable us to choose which methods we want to intercept,  in addition, it has a property IInterceptorSelector help us to filter  interceptor we want to perform on the method.

    ProxyGenerationOptions has a method called AddMixinInstance to help us implement Mixins.


Tutorials: http://kozmic.pl/Tags/Dynamic%20Proxy/default.aspx



posted @ 2010-01-04 16:19  芭蕉  阅读(461)  评论(0编辑  收藏  举报