Search code examples
c#dynamicproxylinfu

Dynamic Proxy generation with LinFu


I am trying to build a dynamic proxy for an interface with LinFu. The proxy should just implement the getter methods of the properties that are defined by the interface and return for instance a value from a dictionary, where the key is the property name.

link text


Solution

  • Try:

    // The interceptor class must implement the IInterceptor interface
    var yourInterceptor = new YourInterceptor();
    var proxyFactory = new ProxyFactory();
    IYourInterface proxy = proxyFactory.CreateProxy<IYourInterface>(yourInterceptor);
    // Do something useful with the proxy here...