title: Parameter based bindings in ninject 2.0
body: <p>I want to use conditional binding in ninject, based on passed parameters. I have something like below:</p>
  
  <pre><code>public class Subject
  {
  }
  
  public interface ITarget
  {
  }
  
  public class Target1 : ITarget
  {
  }
  
  public class Target2 : ITarget
  {
  }
  </code></pre>
  
  <p>And now I need to instantiate ITarget interface:</p>
  
  <pre><code>    public void MethodName(IKernel kernel)
      {
          ITarget target1 = kernel.Get&lt;ITarget&gt;(new Parameter("name", new Subject(), true)); // Should be instance of Target1
          ITarget target2 = kernel.Get&lt;ITarget&gt;(); // Should be instance of Target2
      }
  </code></pre>
  
  <p>I have problems to define proper bindings. I tried the following:</p>
  
  <pre><code>kernel.Bind&lt;ITarget&gt;().To&lt;Target1&gt;().When(Predicate);
  kernel.Bind&lt;ITarget&gt;().To&lt;Target2&gt;();
  
  private bool Predicate(IRequest request)
  {
      IParameter parameter = request.Parameters.Count == 0 ? null : request.Parameters[0];
      if (parameter == null)
      {
          return false;
      }
      object parameterValue = parameter.GetValue( /*what to put here?*/);
      return parameterValue != null &amp;&amp; parameterValue.GetType().IsAssignableFrom(typeof(Subject));
  }
  </code></pre>
  
  <p>but I don't know how to get value of passed parameter. I need to pass IContext instance to GetValue method, but don't know how to get valid instance of IContext. Or maybe there is better way to accomplish my task?</p>
  
  <p>EDIT:
  BindingMetadata is better way to solve my problem. See <a href="https://stackoverflow.com/questions/2507881/contextual-bindings-with-ninject-2-0">Contextual bindings with Ninject 2.0</a> for details</p>
  
  <p>Regards</p>