title: Autofac different service resolution based on TypedParameter
body: <p>Is there anyway to get autofac to resolve the service that has a concrete implementation with the constructor that matches a given parameter most specifically.</p>
  
  <p>By this i mean match a constructor for a child type instead of matching the constructor for the base type.</p>
  
  <p>For example i'd like to make the following test pass</p>
  
  <pre><code>[TestFixture]
  public class AutofacResolvTestFixture
  {
      [Test]
      public void test()
      {
          var cb = new ContainerBuilder();
          cb.RegisterType&lt;Child1&gt;();
          cb.RegisterType&lt;Child2&gt;();
          cb.RegisterType&lt;ServiceImpl1&gt;().As&lt;IService&gt;();
          cb.RegisterType&lt;ServiceImpl2&gt;().As&lt;IService&gt;();
          var container = cb.Build();
          var c1=container.Resolve&lt;Child1&gt;();
          var c2=container.Resolve&lt;Child2&gt;();
          var s1 = container.Resolve&lt;IService&gt;(new TypedParameter(c1.GetType(), c1));
          var s2 = container.Resolve&lt;IService&gt;(new TypedParameter(c2.GetType(), c2));
          Assert.That(s1, Is.InstanceOf&lt;ServiceImpl1&gt;());
          Assert.That(s2, Is.InstanceOf&lt;ServiceImpl2&gt;());
          Assert.That(s1.ConstructorParam, Is.SameAs(c1));
          Assert.That(s2.ConstructorParam, Is.SameAs(c2));
      }
  }
  
  public class baseClass {}
  public class Child1 : baseClass{}
  public class Child2 : baseClass{}
  
  public interface IService
  {
      baseClass ConstructorParam { get; }
  }
  
  public class ServiceImpl1 : IService
  {
      private baseClass _b;
      public ServiceImpl1(baseClass b)
      {
          _b = b;
      }
  
      public baseClass ConstructorParam
      {
          get
          {
              return _b;
          }
      }
  }
  
  
  public class ServiceImpl2 : IService
  {
      private baseClass _b;
      public ServiceImpl2(Child2 b)
      {
          _b = b;
      }
  
      public baseClass ConstructorParam
      {
          get
          {
              return _b;
          }
      }
  }
  </code></pre>
  
  <p>My goal is to make IService, IEditor and be able to resolve the IEditor for a type by passing it to autofac.  I want to do this so that i can "override" the editor for a type by simply inheriting IEditor and using the appropriate constructor type that that IEditor is for.</p>
  
  <p>Thank you.</p>