Search code examples
c#.netproxycastle-dynamicproxydynamic-proxy

Generating Interface Proxies


Ran into an issue with a class; I have a class that looks like:

public class MyPresenter
{
    public MyPresenter(IMyView view) { }
}

public class SomePresenter
{
    public SomePresenter(ISomeView view) { }
}

The custom views inherit from a base IView instance. I ran into a situation where I need to create a custom class on the fly that implements IMyView or ISomeView (depending on some scenario) and access the model, and I was thinking I could use a tool like Castle DynamicProxy to do it. But I'm not quite sure where to start, and I need to be able to create a custom IMyView or other class instance on the fly.

Thanks.


Solution

  • When I needed proxies, I found this tutorial from Krzysztof Koźmic to be invaluable.