title: How does one dynamically add new bindings using Ninject's DI during runtime?
body: <p>So I'm attempting to use a combination of MEF and Ninject in an application I'm writing.  Basically I'm adding in extensions via MEF during runtime.  I don't understand how (or if it's even possible to) I can update Ninject's bindings during runtime.</p>
  
  <p>For example, say I have the following item imported by MEF:</p>
  
  <pre><code>[Export(typeof(ICar))]
  public class BmwCar : ICar
  {
      private ICarLogger _carLogger;
  
      public BmwCar(ICarLogger carLogger)
      {
          _carLogger = carLogger;
      }
  
      public static string Type
      {
          get { return "Sedan"; }
      }
  
      public string GetBrand()
      {
          return "BMW";
      }
  
      public static Type InterfaceType { get { return ICar; } }
      public static Type CarType { get { return GetType(); } }
  }
  </code></pre>
  
  <p>Now normally if I knew this item at compile time I could just create a Ninject Module with the following bindings like:</p>
  
  <pre><code>public class NinjectSetup : NinjectModule
  {
      public override void Load()
      {
          Bind&lt;CarLogFactory&gt;().ToSelf().InSingletonScope();
          Bind&lt;ICarLogger&gt;().ToMethod(x =&gt; x.Kernel.Get&lt;CarLogFactory&gt;(new ConstructorArgument("vehicleName", BmwCar.Type)).WhenInjectedInto&lt;BmwCar&gt;();
      }
  }
  </code></pre>
  
  <p>So the problem is this line:</p>
  
  <pre><code>Bind&lt;ICarLogger&gt;().ToMethod(x =&gt; x.Kernel.Get&lt;CarLogFactory&gt;(new ConstructorArgument("vehicleName", BmwCar.Type)).WhenInjectedInto&lt;BmwCar&gt;();
  </code></pre>
  
  <p>I'm not sure how I could add something like that dynamically after BmwCar is imported.  Obviously I can't use the generic at run time since type is needed during compile time.  Because I can't use generics at run time it seems doing something like:</p>
  
  <pre><code>var binding = new BindingBuilder&lt;ICarLogger&gt;(new Binding(typeof(ICarLogger)), this.Kernel).ToMethod(x =&gt; x.Kernel.Get&lt;CarLogFactory&gt;(new ConstructorArgument("vehicleName", imported.Type)).WhenInjectedInto&lt;imported.CarType&gt;();
  </code></pre>
  
  <p>is not an option.  Anyone aware of away to create new bindings during runtime?</p>