title: Make .NET Core DI auto resolve class by generic interface / abstract class implementation
body: <p>Is there a way in .NET Core to register a generic interface, and make it resolve a class that matches a certain implementation.</p>
  
  <p>For example, I have the following interface:</p>
  
  <pre><code>public interface IMapper&lt;TFrom, TTo&gt;
  {
  }
  </code></pre>
  
  <p>I also have an abstract class:</p>
  
  <pre><code>public abstract class Mapper&lt;TFrom, TTo&gt; : IMapper&lt;TFrom, TTo&gt;
  {
      protected Mapper()
      {
          // some generic stuff
      }
  
      public abstract TTo Map(TFrom);
  }
  </code></pre>
  
  <p>I can then create an implementation like so:</p>
  
  <pre><code>public class UserMapper : Mapper&lt;Domain.User, Entity.User&gt;
  {
      public override Entity.User Map(Domain.User from)
      {
          // do mapping
      }
  }
  </code></pre>
  
  <p>Is there a way, using the default .NET Core DI to register <code>IMapper&lt;,&gt;</code>, and let it auto resolve the class?</p>
  
  <p>So if I for example would do this somewhere in code:</p>
  
  <pre><code>class SomeClass
  {
      public SomeClass(IMapper&lt;Domain.User, Entity.User&gt; mapper) {}
  }
  </code></pre>
  
  <p>That it somehow knows that it should resolve the class <code>UserMapper&lt;Domain.User, Entity.User&gt;</code>?</p>
  
  <p>The reason is that it's a little verbose to manually register each and every mapper, specific to an implementation. So I'm hoping <code>Microsoft.DependencyInjection</code> is smart enough to automatically resolve its implementation somehow.</p>