title: Autofac optional/lazy dependencies
body: <p>If I put Lazy in constructor of my object, and X is not registered in container I got dependency resolution exception.</p>
  
  <p>Why am I getting this exception? I dislike it, because I cannot choose component at runtime. Example usecase:</p>
  
  <pre><code>class Controller
  {
     public Controller(Lazy&lt;A&gt; a, Lazy&lt;B&gt; b) { /* (...) */ }
  
   Lazy&lt;A&gt; a;
   Lazy&lt;B&gt; b;
  
   public IActionResult Get(){
    if(someConfig)
      return Json(a.Value.Execute());
    else
      return Json(b.Value.Execute());
   }
  }
  </code></pre>
  
  <p>To do so I need to register both components A an B. My program fails even if B is never used. I would like to have B be optional, and still managed by autofac.</p>
  
  <p>This is even bigger issue if I have list of components, and want only one to be used. For example:</p>
  
  <pre><code>class Controller
  {
      Controller(IEnumerable&lt;Component&gt; components) { /* (...) */ }
  
      IActionResult Get()
      {
          return components.First(n =&gt; n.Name == configuredComponent).Execute();
  
      }
  
  }
  </code></pre>
  
  <p>I am no longer getting exception is something is not registered, however still everything is constructed. Also it would be awkward to use.</p>