2

Is there a way to prevent Castle Windsor from automatically injecting dependencies into properties (besides the [DoNotWire] attribute)?

David Gardiner
  • 16,892
  • 20
  • 80
  • 117
Markus Dulghier
  • 1,580
  • 1
  • 17
  • 20

2 Answers2

1

If you want to turn off property injection globally, you can use this code:

// We don't want to inject properties, only ctors
var propInjector = Kernel.ComponentModelBuilder
                     .Contributors
                     .OfType<PropertiesDependenciesModelInspector>()
                     .Single();

Kernel.ComponentModelBuilder.RemoveContributor(propInjector);

(Code sample taken from Castle Windsor docs - refer for further details)

Jan Palas
  • 1,865
  • 1
  • 23
  • 35