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

邮差的信 提交于 2019-12-01 18:00:17

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.

Crixo

I may say you should not use a container directly into your class library. Your class library should have dependecies between classes within the library. The application(Front-End / root of the apps graph) will use a container to resolve all dependencies including those into your class library. IMHO using an IoC within a class library smells like a ServiceLocator.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!