Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are on the right track - what you need to do is configure the parameters of each component, supplying the parameter named "P" with the value "${foo}" or "${foobar}" depending on your scenario, here's a working xunit fact (scroll down towards the bottom for the actual registration code) which demonstrates your scenario.</p> <pre><code>namespace Question651392 { public class First123 : I { public AbstractLetter P { get; set; } } public class Second123 : I { public AbstractLetter P { get; set; } } public class FirstABC : I { public AbstractLetter P { get; set; } } public class SecondABC : I { public AbstractLetter P { get; set; } } public interface I { AbstractLetter P { get; set; } } public abstract class AbstractLetter { } public class B : AbstractLetter { } public class A : AbstractLetter { } public class RegistrationFacts { [Fact] public void EnsureParametersCanBeSetWhenRegisteringComponentsInBulk() { WindsorContainer Container = new WindsorContainer(); Container.Register(Component.For&lt;A&gt;().Named("foo")); Container.Register(Component.For&lt;B&gt;().Named("foobar")); Container.Register( AllTypes.Pick() .FromAssembly(GetType().Assembly) .If(t =&gt; t.Name.EndsWith("ABC")) .Configure(c =&gt; c.LifeStyle.Is(LifestyleType.Transient)) .Configure(c=&gt;c.Parameters(Parameter.ForKey("P").Eq("${foo}"))) .WithService.Select(new[] { typeof(I) }) ); Container.Register( AllTypes.Pick() .FromAssembly(GetType().Assembly) .If(t =&gt; t.Name.EndsWith("123")) .Configure(c =&gt; c.LifeStyle.Is(LifestyleType.Transient)) .Configure(c =&gt; c.Parameters(Parameter.ForKey("P").Eq("${foobar}"))) .WithService.Select(new[] { typeof(I)}) ); var all = Container.ResolveAll&lt;I&gt;(); var firstABC = all.Single(i =&gt; i is FirstABC); Assert.IsType(typeof(A), firstABC.P); var first123 = all.Single(i =&gt; i is First123); Assert.IsType(typeof (B), first123.P); Assert.Equal(4, all.Count()); } } } </code></pre> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload