简体   繁体   中英

Constructor dependency injection on not a controller classes

I'm using old version of Castle Windsor - 2.5.1 and ASP.NET MVC. Can I use dependency injection for class other then controllers? I got some services which I'm using in my ASP.NET MVC project and I would like to inject some object to those service in those constructors. Is that possible?

Yes of course you can use this. Inversion of Control is a principle used by frameworks as a way to allow developers to extend the framework or create applications using it. The basic idea is that the framework is aware of the programmer's objects and makes invocations on them.

Hope this helps.

Yes you can! Castle Windsor is just an framework to help with dependency injection you can use it with any code - not just ASP.Net MVC and controller classes.

Yes, you can use dependency injection any any C# or non C# class. In web, desktop, console app. Anywhere. The same way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM