title: Autofac Resolve using delegate factory by type
body: <p>I am using Autofac for IoC in my project. Due to some legacy software libraries I must pass some services to the controller that can't be resolved, and must be passed as parameter.</p>
  
  <p>I've made a generic control using delegate factories like this:</p>
  
  <pre><code>public MyClass&lt;TController, TInterface&gt; {
  
       private delegate TController ControllerFactory(TInterface service);
  
       protected TController _myController;
       protected TController Controller {
           get
           {
               return _controller 
                 ?? (_controller = ServiceLocator.Resolve&lt;ControllerFactory&gt;()
                                      .Invoke(this);
           }
       }
  
  }
  </code></pre>
  
  <p>This works perfect, but for this to work I need the controller's service parameter name and the delegate service parameter name be the same, because as I have read, Autofac pairs the parameter BY NAME !! </p>
  
  <p>I've seen you can do it by type registering the class with generic Func&lt;>, but due to the legacy app I would need to leave "clean" registrations i.e.: </p>
  
  <pre><code>containerBuilder.RegisterType&lt;MyController&gt;();
  </code></pre>
  
  <p>Does anyone know if it's possible to make the delegate match the parameter by type??</p>