Castle Windsor: Turn Off Automatic Property Injection

Suppose you have the following component:

public class SomeComponent
{
    public IEmailSender EmailSender { get; set; }
}

Further, you're using Windsor for IoC and have registered both this component and an IEmailSender in the container.  Whenever 'SomeComponent' is resolved, it's EmailSender will automatically be set by the container.  If you don't want this behavior, you can tell Windsor, on a per-property basis, to not auto-resolve the property with the "DoNotWire" attribute:

public class SomeComponent
{
    [DoNotWire]
    public IEmailSender EmailSender { get; set; }
}
Source: Turn off property injection/resolution
Technorati Tags: ,,,

No Comments