I want to override the constructor arguments of a nested dependency. I
don't understand reason why I shouldn't do this. The only way I've
found to achieve this is to remove the Lambda expression and actually
resolve the object at the point of registration:

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            IWindsorContainer container = new WindsorContainer();
            container.Kernel.Register(Component.For<IHeart>
().ImplementedBy<Heart>().Parameters(Parameter.ForKey("age").Eq
("1")));


            var kernel2 = container.Kernel.Register
(Component.For<IPerson>().ImplementedBy<Person>
().LifeStyle.Transient.DependsOn
                                          (Property.ForKey("heart").Eq
                                          (
                                            new Func<IHeart>(() =>
container.Resolve<IHeart>(new { age = 99 }))
                                          )));



            var person = container.Resolve<IPerson>();
            Console.Read();
        }

 }



    public class Person : IPerson
    {
        private readonly IHeart heart;

        public Person(IHeart heart)
        {
            this.heart = heart;
        }


    }

    public interface IPerson
    {
    }

    public interface IHeart
    {
    }

    class Heart : IHeart
    {
        public Heart(int age)
        {
            Console.WriteLine(age);
        }

    }

}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to