C# Ninject Parameter based Binding
<p>I am using Ninject to inject dependencies.
I have the following class structure :</p>

<pre><code>public interface IClass
{
}

public class Class: IClass
{
 public virtual void Method(Object context)
 {
  --------
 }
}   

public class Class1: IClass
{
 public override void Method(Object context)
 {
  --------
 }
}

public class Class2: IClass
{
 public override void Method(Object context)
 {
  --------
 }
}
</code></pre>

<p><code>context</code> contains - HasBilling , HasPayment  properties along with other more properties.</p>

<p><code>Method()</code> is invoked by using factory pattern:</p>

<pre><code>public interface IClassFactory
    {
        IClass CreateClass();
    }

_classFactory.CreateClass().Method(....)
</code></pre>

<p>So when the parameter <code>HasBilling</code> equals to <code>true</code> then i have to invoke <code>Method()</code> of <code>Class1</code> implementation, similarly if <code>HasPayment</code> equals to true, <code>Method()</code> of <code>Class2</code> implementation must be called.</p>

<p>Using Ninject Binding, I tried these bindings, but neither one worked:</p>

<pre><code>Bind&lt;IClass&gt;().To&lt;Class1&gt;().When(x =&gt; x.Target.Member.Name.Contains("HasBilling").Equals(true));
</code></pre>

<p>Tried this, but no luck:</p>

<pre><code>Bind&lt;IClass&gt;().To&lt;Class1&gt;().WithMetadata("HasBilling", true);
</code></pre>

<p>Please can some one help me with what bindings needs to be set to call <code>Class1</code> , <code>Class2</code> method(<code>Method</code>) based on a parameter value(<code>HasBilling,HasPayment</code>) .</p>

<p>Many Thanks In Advance,</p>

<p>Thanks,
WH</p>