title: how do I register multiple interface implementations with multiple keys in castle windsor?
body: <p>I have a validation interface like so:</p>
  
  <pre><code>public interface IValidation&lt;T&gt; {
    bool IsValid(T item, ref AggregateException fail);
  }
  </code></pre>
  
  <p>I have a file importer that needs several validation interfaces</p>
  
  <pre><code>public FileImporter {
    IEnumerable&lt;IValidation&lt;Patient&gt;&gt; Validators { get; set; }
  
    public FileImporter(IWindsorContainer container) {
      // the ResolveAll method does not do this
      Validators = container.ResolveAll&lt;IValidation&lt;Patient&gt;&gt;("fileValidation");
    }
  }
  </code></pre>
  
  <p>I also have another class that has more validators but uses some of the same ones used in <code>FileImporter</code>.</p>
  
  <pre><code>public PatientService {
    IEnumerable&lt;IValidation&lt;Patient&gt;&gt; Validators { get; set; }
  
    public PatientService(IWindsorContainer container) {
      // the ResolveAll method does not do this
      Validators = container.ResolveAll&lt;IValidation&lt;Patient&gt;&gt;("userInputValidation");
    }
  }
  </code></pre>
  
  <p>For example I have two validators <code>LastNameValidator</code> and <code>DateOfBirthValidator</code>. <code>LastNameValidator is used in both the</code>FileImporter<code>and the</code>PatientService<code>.</code>DateOfBirthValidator<code>is only used in the</code>PatientService` class. The implementation of these two classes are below the question.</p>
  
  <p><strong>My question is how can i wire up these two classes so that they are used as described above. And what method call should I make to resolve them?</strong></p>
  
  <pre><code>public class LastNameValidator : IValidation&lt;Patient&gt; {
    public bool IsValid(Patient p, ref AggregateException fail) {
      var isValid = !string.IsNullOrWhitespace(p.LastName))
      if (!isValid)
          // update fail
      return isValid;
    }
  }
  
  public class DateOfBirthValidator : IValidation&lt;Patient&gt; {
    public bool IsValid(Patient p, ref AggregateException fail) {
  
      if (!p.DateOfBirth.HasValue) {
          // update fail, can't be empty
          return false;
      }
      if (p.DateOfBirth.Value &gt; DateTime.Now) {
          // update fail, can't be in future
          return false;
      }
      return true;
    }
  }
  </code></pre>