title: Given a ContainerBuilder, can I register a missing dependency handler?
body: <p>I am trying to make a method with the following signature:</p>
  
  <pre class="lang-cs prettyprint-override"><code>void Chain(ContainerBuilder builder, IServiceProvider fallbackServiceProvider)
  {
     // ...
  }
  </code></pre>
  
  <p>The idea is that <code>Chain</code> can be used as follows:</p>
  
  <pre class="lang-cs prettyprint-override"><code>IServiceProvider fallbackProvider = someExternalProvider;
  var builder = new ContainerBuilder();
  
  // Custom registration might happen before and/or after the call to Chain
  builder.Register&lt;MyCustomService&gt;().As&lt;IMyCustomService&gt;();
  builder.Register&lt;MyExternalServiceReplacement&gt;.As&lt;IExternalService&gt;();
  
  Chain(builder, someExternalProvider);
  
  IContainer container = builder.Build();
  
  // customService should be a MyCustomService
  var customService = container.Resolve&lt;IMyCustomService&gt;();
  
  // replacedService should be overridden by MyExternalServiceReplacement
  // even though an IExternalService also exists in someExternalProvider
  var replacedService = container.Resolve&lt;IExternalService&gt;();
  
  // nonReplacedService should come from someExternalProvider since
  // no IExternalService2 was registered with the ContainerBuilder
  var nonReplacedService = container.Resolve&lt;IExternalService2&gt;();
  </code></pre>
  
  <p>Ideally there would be some type of missing dependency handler that I could register with the ContainerBuilder.</p>
  
  <p>Alternatively, I could probably get by with some way to register a component that could intercept every call to <code>Resolve*</code>, <code>TryResolve*</code>, etc... This would also need to intercept the dependency resolution for constructor injection.</p>
  
  <p>Unfortunately, there is no way to query the IServiceProvider to get every service it provides. I can only call into the <code>object IServiceProvider.GetService(Type serviceType)</code> method of the <code>fallbackServicProvider</code>.</p>