views:

289

answers:

0

I'm looking at using unity to resolve some interfaces but am not sure about it's performance in terms of scalability. I've registered my dependency types in the web.config and then have this code for a MVP type approach which takes the current web page as the view (IView) in the constructor of the presenter. The code below is taken from the code behind for one of the pages

public void RegisterViewForPresenter<T>(object view)
{
    Container.Configure<InjectedMembers>()
        .ConfigureInjectionFor<T>(
        new InjectionConstructor(view)
    );
}

RegisterViewForPresenter<MyPresenter>(this);
ThisPagePresenter = Container.Resolve<MyPresenter>();


public class MyPresenter
{
public void MyPresenter(IView view)
{...}
}

The MyPresenter class has some dependency properties within it. Unfortunately I lack the knowledge on how to specify a web page class as the interface to the presenter in the web.config as it's not a compiled web application but a web site. So this is the best approach I could find. My concern is that I'm asking Unity to resolve the presenter every time the page gets hit. I've read that Unity caches the dependencies but wanted to be sure that performance would be sufficient. This presenter can't be a singleton before anyone suggests that.

I tried to hit my local IIS with multiple requests via Fiddler just to see what happened and after a while (~100 simultaneous requests) I got a Unity exception about resolving references.

Can anyone offer any tips on how to manage this better or to offer some better benchmarking on Unity with web sites?

Thanks