This project is read-only.

Property Injection

Apr 28, 2013 at 6:24 PM
After reading the docs, I know you'll hate this, but it was so easy to get property injection that I wanted to give you kudos. It's nice when the opinions of the framework don't completely preclude doing things "the wrong way".
public class PropertyInjector : IPropertySelectionBehavior
    readonly Container container;

    public PropertyInjector(Container container)
        this.container = container;

    public bool SelectProperty(Type serviceType, PropertyInfo propertyInfo)
        return this.container.GetRegistration(propertyInfo.PropertyType, false) != null;
this.container.Options.PropertySelectionBehavior = new PropertyInjector(this.container); 
+1 for IPropertySelectionBehavior and for the "ConfigureProperty by Type" code in the other thread that let's us shoot ourselves in the foot without polluting the framework. :-D
Marked as answer by dot_NET_Junkie on 11/5/2013 at 7:40 AM