title: TinyIoC - Multiple Implementations of Interface
body: <p>I am just beginning to learn about IoC and Dependency Injection.  I am planning on doing a MonoTouch project and wanted to use TinyIoC but I wanted to test it out first.  I'm creating a dummy credit card processing console app and I'm having trouble with how to configure TinyIoC since I have multiple implementations of my interface. This is my test app.</p>
  
  <p><strong>Interface</strong>:</p>
  
  <pre><code>public interface IPaymentProcessor
  {
      void ProcessPayment(string cardNumber);
  }
  </code></pre>
  
  <p>Two Implementations of the interface:</p>
  
  <p><strong>VisaPaymentProcessor</strong></p>
  
  <pre><code>public class VisaPaymentProcessor : IPaymentProcessor
  {
      public void ProcessPayment(string cardNumber)
      {
          if (cardNumber.Length != 13 &amp;&amp; cardNumber.Length != 16)
          {
              new ArgumentException("Card Number isn't the correct length");
          }
  
          // some code for processing payment
      }
  }
  </code></pre>
  
  <p><strong>AmexPaymentProcessor</strong></p>
  
  <pre><code>public class AmexPaymentProcessor : IPaymentProcessor
  {
      public void ProcessPayment(string cardNumber)
      {
          if (cardNumber.Length != 15)
          {
              new ArgumentException("Card Number isn't the correct length");
          }
  
          // some code for processing the payment
      }
  }
  </code></pre>
  
  <p>Simple stuff.  Now I have a class that accepts the interface as a parameter in the constructor....</p>
  
  <p><strong>CreditCardProcessor</strong></p>
  
  <pre><code>public class CreditCardProcessor
  {
      public IPaymentProcessor PaymentProcessor { get; set; }
  
      public CreditCardProcessor(IPaymentProcessor processor)
      {
          this.PaymentProcessor = processor;
      }
  
      public void ProcessPayment(string creditCardNumber)
      {
          this.PaymentProcessor.ProcessPayment(creditCardNumber);
      }
  }
  </code></pre>
  
  <p>My console app looks like this....</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          TinyIoCContainer.Current.AutoRegister();
  
          var creditCardProcessor = TinyIoCContainer.Current.Resolve&lt;CreditCardProcessor&gt;();
          creditCardProcessor.ProcessPayment("1234567890123456"); // 16 digits
      }
  }
  </code></pre>
  
  <p>So I am trying to figure out how to tell the <code>Resolve</code> which implementation of the interface to pass to the constructor.  If I run this code, I will always use the <code>VisaPaymentProcessor</code> implementation.</p>
  
  <p>So how can I make TinyIoC pass the <code>AmexPaymentProcessor</code> implementation to the constructor rather than the <code>VisaPaymentProcessor</code>(which seems to be the default)?</p>