title: Register service as self, but as an implementation of another class/service
body: <p>(Edited)</p>
  <p>I'm sorry for the confusing title, but I'm not sure how to formulate myself. I'll just dive into it!</p>
  <p>I have two interfaces:</p>
  <pre><code>public interface IEntityService&lt;T&gt; where T : Entity
  {
      Task&lt;T&gt; GetAsync(string id);
      Task CreateAsync(T entity);
  }
  
  public interface IEntityGetAllService&lt;T&gt; where T : Entity
  {
      Task&lt;List&lt;T&gt;&gt; GetAllAsync();
  }
  </code></pre>
  <p>I also have a class that implements both these interfaces:</p>
  <pre><code>public class EntityService&lt;T&gt; : IEntityService&lt;T&gt;, IEntityGetAllService&lt;T&gt; where T : Entity
  {
      private readonly IEntityRepository&lt;T&gt; _entityRepository;
  
      public EntityService(IEntityRepository&lt;T&gt; entityRepository)
      {
          _entityRepository = entityRepository;
      }
  
      public async Task&lt;T&gt; GetAsync(string id)
      {
          return await _entityRepository.Get(id);
      }
  
      public async Task CreateAsync(T entity)
      {
          await _entityRepository.Create(entity);
      }
  
      public async Task&lt;List&lt;T&gt;&gt; GetAllAsync()
      {
          return await _entityRepository.GetAll();
      }
  }
  </code></pre>
  <p>Now, I create the following service:</p>
  <pre><code>public class FooService : IEntityService&lt;Foo&gt;
  {
      private readonly IEntityService&lt;Foo&gt; _entityService;
  
      public EntityService(IEntityService&lt;Foo&gt; entityService)
      {
          _entityService = entityService;
      }
  
      public Task&lt;Foo&gt; GetAsync(string id)
      {
          return _entityService.GetAsync(id);
      }
  
      public Task CreateAsync(Foo entity)
      {
          _entityService.CreateAsync(entity);
      }
  }
  </code></pre>
  <p>Then I can register <code>FooService</code> as itself. However, one could argue that I could just inject <code>IEntityService&lt;Foo&gt;</code> instead, but that would allow the use of <code>GetAllAsync</code> for the <code>Foo</code> entity, which should not be allowed. Therefore, I want to control what methods to allow, by implementing each interface in the <code>FooService</code>. For example, <code>BarService</code> could implement both <code>IEntityService&lt;Bar&gt;</code> and <code>IEntityGetAllService&lt;Bar&gt;</code>, which would allow all methods for the <code>BarService</code>. The problem here is that each service would do exactly the same, implement IEntityService and perform the exact same methods, but for different entities. Can I automatically register each service to use the implementation of <code>EntityService&lt;&gt;</code>?</p>
  <p>Is this even possible? I've tried several methods, using abstract classes, assembly scanning, manual registration etc., but I can't for the sake of my life understand how to achieve this, if it even is possible.</p>