title: Ninject - Intercept a multiple binding resolution
body: <p>Is there a way to have Ninject call a function when it has trouble with multiple binding resolution ?</p>
  
  <p>Basically, I would like to have this:</p>
  
  <pre><code>static void Main(string[] args)
  {
      StandardKernel k = new StandardKernel();
      k.Bind&lt;IProvideConn&gt;().To&lt;probe1&gt;(); // these bindings are actually done by assembly scanner, I don't know how many types are available
      k.Bind&lt;IProvideConn&gt;().To&lt;probe2&gt;();
      k.Bind&lt;plugin1&gt;().ToSelf();
  
      k.Get&lt;plugin1&gt;(); // Currently throws a "multiple bindings registered" exception
                        //but I would like it to call solveMyIssues.sortThingsOut
  }
  
  public class solveMyIssues
  {
      public IBinding sortThingsOut(IEnumerable&lt;IBinding&gt; availableBindingsForThisResolve)
      {
          int i = AskChoiceFromUser(availableBindingsForThisResolve);
          return availableBindingsForThisResolve[i];
      }
  }
  
  interface IProvideConn0
  {
      void goCrazy();
  }
  
  public class plugin1
  {
      public void talkWithUser(IProvideConn0 pc)
      {
          pc.goCrazy();
      }
  }
  
  public class probe1 : IProvideConn0
  {
      public void goCrazy() {}
  }
  
  public class probe2 : IProvideConn0
  {
      public void goCrazy() {}
  }
  </code></pre>
  
  <p>More context:<br>
  I'm using Ninject in a plugin like architecture. Plugins can use one or more types of connection providers (each connection provider type has an interface that inherits from IMotherConnProv).<br>
  Currently I use the XML extension to map each IProvideConnX to an implementation (each IProvideConnX can have several implementations), but it's quite tedious for users to edit XML files when they want to change connection types.</p>
  
  <p>I made a small application that helps them modify the XML file with shiny buttons and everything, but I feel like there should be a more dynamic way to do that (Ninject is about freeing myself from XML, right ?).<br>
  So I would like to use the assembly scanner to discover all possible choices, and somehow tell Ninject at runtime which binding to choose from (depending on user choice).</p>
  
  <p>Any ideas ? (I had a look at <a href="https://stackoverflow.com/a/6171199/1171260">that solution</a> but I can't see how to adapt it to an indefinite number of interfaces and implementations)</p>