I'm pretty sure it works like this by design. Inline parameters aren't passed down the resolution chain, because it breaks the abstraction of the IServiceA interface. Calling resolve at that point (i.e. Create on the factory) you shouldn't know that IServiceA's implementation needs a IServiceB.
Krzysztof explains it with more detail in this stackoverflow question: http://stackoverflow.com/questions/3904951/castle-windsor-ioc-passing-constructor-parameters-to-child-components Depending on what secondLevelDependency is depends on how you'd go about implementing this following dependency injection principles. For example, if it is an app.config entry then you could use DependsOn when you register the component, or DynamicProperties if it is a global: http://stw.castleproject.org/Windsor.Inline-Dependencies.ashx Another option is to be explicit and expose to the factory consumer that inline dependency of IServiceB. public interface IMyFactory { IServiceA CreateA(IServiceB serviceB); IServiceB CreateB(string secondLevelDependency); } On Thu, Oct 16, 2014 at 6:22 AM, Phil <[email protected]> wrote: > Hi > > I would like to know if this scenario is supported by Windsor and if not, > is there any workaround. > > Thanks > Phil > > > public Interface IMyFactory > { > IServiceA Create(string secondLevelDependency); > } > > public class ServiceA : IServiceA > { > public ServiceA(IServiceB serviceB){...} > } > > public class ServiceB : IServiceB > { > public string SecondLevelDepdencency {get; private set;} > public ServiceB(string secondLevelDepdencency) > {this.SecondLevelDepdencency = secondLevelDepdencency;} > { > > > > [Test] > public void ShouldPushSecondLevelDependencyParameters() > { > kernel.Register(Component.For<IServiceB>().ImplementedBy<ServiceB>()); > kernel.AddFacility<TypedFactoryFacility>(); > kernel.Register(Component.For<IMyFactory>().AsFactory()); > > var factory = kernel.Resolve<IMyFactory>(); > > var service = factory.Create("value"); > service.Should().NotBeNull(); > service.SecondLevelDepdencency.Should().Be("value"); > } > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected] > . > Visit this group at http://groups.google.com/group/castle-project-users. > For more options, visit https://groups.google.com/d/optout. > -- Jono -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/castle-project-users. For more options, visit https://groups.google.com/d/optout.
