title: Autofac resolve Generic type with constructor parameters at run time
body: <p>I have a generic class <code>Logger&lt;TProvider&gt; where TProvider : ILogProvider</code> which I'd like to configure dependency injection for with Autofac.</p>
  
  <p>This class also has a constructor:</p>
  
  <pre><code>public Logger(LogType loggerType)
  </code></pre>
  
  <p>Which is currently used like this:</p>
  
  <pre><code>var logger = new Logger&lt;Log4NetLogProvider&gt;(LogType.CMS);
  </code></pre>
  
  <p>I was wondering if this could be dependency injected or will that not be possible due to type/constructor parameter required?</p>
  
  <p>I'm aware of the <code>RegisterGeneric</code> method, e.g:</p>
  
  <pre><code>builder.RegisterGeneric(typeof(Logger&lt;&gt;)).AsSelf()
  </code></pre>
  
  <p>I was wondering how I can tell autofac which <code>TProvider</code> was passed in and also provide the constructor parameter <code>LogType</code>? Or is this not a good candidate for DI?</p>