title: Unity Register For One Interface Multiple Object and Tell Unity Where to Inject them
body: <p>Hi I have been having trouble trying to tell Unity that for an Interface if it has multiple implementations , I want it to inject them in different classes.Here is what I mean:</p>
  
  <p>Let's say I have an interface <code>IProductCatalogService</code> and two implementations 
  <code>ProductCatalog : IProductCatalogService</code> and <code>ProductCatalogService : IProductCatalogService</code>.</p>
  
  <p>How would I go about telling Unity that for Class A I want in my constructor passed an instance of type <code>ProductCatalog</code> and for Class <code>B</code> I want an instance of <code>ProductCatalogService</code>.</p>
  
  <p>I am using Unity in an ASP.NET Web API project and I have set the resolver in the <code>GLobalConfiguration</code>.</p>
  
  <p>For simple 1 to 1 registrations everything works.</p>
  
  <p>Here is what I have tried but it does not seem to work:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class DependencyServiceModel
  {
      public Type From { get; set; }
      public Type To { get; set; }
      public IEnumerable&lt;Type&gt; ForClasses { get; set; }
  }
  
  public void RegisterTypeForSpecificClasses(DependencyServiceModel dependencyService)
  {
      foreach (var forClass in dependencyService.ForClasses)
      {
          string uniquename = Guid.NewGuid().ToString();
  
          Container.RegisterType(dependencyService.From, 
              dependencyService.To, uniquename);
  
          Container.RegisterType(forClass, uniquename, 
              new InjectionConstructor(
                  new ResolvedParameter(dependencyService.To)));
      }
  }
  </code></pre>
  
  <p>In the <code>DependencyServiceModel</code>, <code>From</code> is the interface, <code>To</code> is the object to witch I want to instantiate and <code>ForClasses</code> are the Type for which I want to use the <code>To</code> Object.</p>