Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is best practise when instantiating a Castle Windsor container in a class library? [duplicate]

I am wondering where the best place to instantiate the castle Windsor container is in a class library.

Should I simply do it in the constructor of the class I am using or is there a single entry point for assemblies that I am unaware of?

Thanks.

like image 747
shenku Avatar asked May 11 '12 07:05

shenku


1 Answers

The configuration of an injected object graph is entirely dependent on the needs of the application that actually uses it. The point of using the container is to be able to configure dependencies at runtime - a library doesn't know anything about how it's going to be used.

Library classes should be written in a way that allows you to use any container you like, or poor-man's-dependency-injection as the consumer sees fit. Coupling a library to a container is a smell.

like image 109
Tom W Avatar answered Sep 19 '22 03:09

Tom W