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.
Limitation:
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