title: autofac: registering the same class more than once with different dependencies
body: <p>Given the following heirarchy:<br>
  I need to resolve one instance of <strong><code>ProducerRepository</code></strong> per registered <code>IParser</code> dependency when an <strong><code>IEnumerable&lt;ISourceRepository&lt;IDatum&gt;&gt;</code></strong> is resolved.</p>
  
  <pre><code>public class ProducerRepository : ISourceRepository&lt;Data&gt;
  {
      public ProducerRepository(IRepository repository)
      {}
  }
  
  public interface ISourceRepository&lt;out T&gt; where T : class, IDatum
  {}
  
  public class Repository : IRepository
  {
      public Repository(IParser parser)
      {}
  }
  
  public class ParserTypeOne : IParser {}
  public class ParserTypeTwo : IParser {}
  </code></pre>
  
  <p>I need to register <code>ProducerRepository</code> as follows.</p>
  
  <pre><code>builder.RegisterType&lt;ProducerRepository&gt;()           
  .WithParserTypeOne() // how do I specify this as a particular dependency
  .As&lt;ISourceRepository&lt;IDatum&gt;();
  
  builder.RegisterType&lt;ProducerRepository&gt;()          
  .WithParserTypeTwo() // another type of parser.
  .As&lt;ISourceRepository&lt;IDatum&gt;&gt;();
  
  // OR: better still if at all possible...
  builder.RegisterType&lt;ProducerRepository&gt;() // one of these for each underlying dependency
  .WithEachPossibleTypeOfParser() // one for each dependency
  .As&lt;ISourceRepository&lt;IDatum&gt;&gt;();
  </code></pre>
  
  <p>I need to know how to register the class twice, once with each type of dependency, so that when an <strong><code>IEnumerable&lt;ISourceRepository&lt;IDatum&gt;&gt;</code></strong> is resolved I get a separate instance of ProducerRepository for each different implementation of the parser.</p>
  
  <p>Better still, it would be nice to be able to register a separate <code>ProducerRepository</code> for each instance of the parser found in the assembly scan, and add it.</p>
  
  <p>I was hoping not to have to resort to changing the implementation to use <code>Keyed</code> or <code>Meta</code> registrations as that locks in each dependency and changes the implementation. If that is the only way of doing it, I will accept the answer. <em>I am hoping for a generic way to register all the possible implementations</em>.</p>