title: Resolve singleton generics where T is a controller that implements interface
body: <p>I have this situation:</p>
  
  <pre><code>public class MyController : Controller, ILoggable
  {
       private readonly ILogger&lt;ILoggable&gt; _logger;
  
       public MyController(ILogger&lt;ILoggable&gt; logger)
       {
           this._logger = logger;
       }
       ...
  }
  </code></pre>
  
  <p>I want to resolve <code>ILogger&lt;ILoggable&gt;</code> as singleton and <code>ILoggable</code> as Transient.
  In my startup I tried with this:</p>
  
  <pre><code>services.AddSingleton(typeof(ILogger&lt;&gt;), typeof(LoggerImpl&lt;&gt;));
  </code></pre>
  
  <p>But I am not able to resolve <code>ILoggable</code> because is a controller and I do not understand which is the best approach.</p>
  
  <p><strong>EDIT</strong>
  Here is the problem:
  I cannot declare <code>ILogger&lt;MyController&gt;</code> inside my controller because <code>ILogger&lt;ILoggable&gt;</code> is used in third part code. I try to explain better my problem without use dependency injiection.</p>
  
  <p>I have a third part class that has a constructor like this></p>
  
  <pre><code>Public ExternalClass(ILogger&lt;ILoggable&gt; logger) {…}
  </code></pre>
  
  <p>Now, in my controller I need to use this external class, but obviously I cannot do something like this:</p>
  
  <pre><code>public class MyController : Controller, ILoggable
  {
       private readonly ILogger&lt;MyController&gt; _logger;
  
       public MyController(ILogger&lt;MyController&gt; logger)
       {
           this._logger = logger;
           ExternalClass c = new ExternalClass(logger); //Here the error because logger is of type ILogger&lt;MyController&gt;, not ILogger&lt;ILoggable&gt;
       }
       ...
  }
  </code></pre>
  
  <p>I need to solve that via DI.</p>
  
  <p>Can anyone help me please?
  Thank you</p>