title: Pass runtime value to constructor using Simple Injector abd WebFormsMVP
body: <p>I'm trying to combine <strong>SimpleInjector with WebFormsMvp</strong>.</p>
  
  <p>To facilitate DI WebFormsMvp provides the <code>IPresenterFactory</code> interface.<br />
  It contains the <code>Create</code> method which provides the <strong>presenter type to resolve</strong> and the <strong>view instance</strong>.<br />
  I need to <strong>inject</strong> the <strong>view instance into</strong> the <strong>constructor of</strong> the <strong>presenter</strong>.<br />
  The presenter <strong>also</strong> has <strong>other dependencies</strong> that need creating <strong>by the container</strong>.</p>
  
  <p>This is what I got so far, but it is not ideal.<br />
  What's the <strong>correct solution</strong> for the problem?</p>
  
  <p>Presenter constructor:</p>
  
  <pre><code>public FooPresenter(IFooView view, IClientFactory clientFactory) : base(view)
  </code></pre>
  
  <p>Factory:</p>
  
  <pre><code>public class SimpleInjectorPresenterFactory : IPresenterFactory
  {
      private readonly Container _container;
      private IView _currentView;
  
      public SimpleInjectorPresenterFactory()
      {
          _container = new Container();
  
          Func&lt;Type, bool&gt; isIView = 
              type =&gt; typeof(IView).IsAssignableFrom(type);
  
          _container.ResolveUnregisteredType += (s, e) =&gt; {
              if (isIView(e.UnregisteredServiceType))
                  e.Register(() =&gt; _currentView);
          };
      }
  
      public IPresenter Create(Type presenterType, Type viewType, IView viewInstance)
      {
          lock (_currentView)
          {
              _currentView = viewInstance;
              return _container.GetInstance(presenterType) as IPresenter;
          }
      }
  }
  </code></pre>