When I have a class with public property, and several components of
property type are registered. I expected that castle to  push the
component with name matching the property name if exists.

here is code illustrating that it is not so but at the same moment
DependencyKey of prop dependency is set to property name.

Looks quite strange , may be a bug...



  public class ClassWithProperty
    {
        public IComparable Value { get; set; }
    }


  [Test]
        public void PropertyInjectionTest()
        {
            WindsorContainer c=new WindsorContainer();
            c.Register(
                Component.For<ClassWithProperty>(),
                Component.For<IComparable>().Instance("string1"),
 
Component.For<IComparable>().Instance("string2").Named("Value")
                );
            ComponentModel model = c.Kernel.GraphNodes.Where(n => (n
as ComponentModel).Implementation ==
typeof(ClassWithProperty)).First() as ComponentModel;
            var prop = typeof (ClassWithProperty).GetProperty("Value",
BindingFlags.Public | BindingFlags.Instance);
            PropertySet propSet =
model.Properties.FindByPropertyInfo(prop);
            Assert.AreEqual("Value",
propSet.Dependency.DependencyKey,"Dependency key was not set");

            var instance = c.Resolve<ClassWithProperty>();
            Assert.AreEqual("string2", instance.Value, "wrong value
was injected");

        }

-- 
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