Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace Spring.Net IoC with another Container (e.g. Ninject)

I'm curious to know if it's possible to replace Spring.Net's built-in IoC container with Ninject. We use Ninject on my team for IoC in our other projects so I would like to continue using that container if possible.

Is this possible? Has anyone written a Ninject-Spring.Net Adapter??

Edit

I like many parts of the Spring.Net package (the data access, transactions, etc.) but I don't really like the dependency injection container. I would like to replace that with Ninject

Thanks

like image 811
Jeffrey Cameron Avatar asked Jan 10 '10 20:01

Jeffrey Cameron


2 Answers

I meant everything I said in my other answer. However, I also realize that if you currently use Spring.NET as a Service Locator (i.e. you have code sprinkled all over your code base that queries the container), that answer may not be very helpful.

If this is the case, you may find the Common Service Locator project helpful. It is an open source project that attempts to abstract away specific Service Locators, hiding them all behind a common interface.

While they don't seem to have a Ninject implementation, they do have a Spring.NET implementation, so maybe that can take you halfway there.

For the record, I consider Service Locator an anti-pattern, and find that the Common Service Locator is the wrong answer to the wrong problem. In my eyes, it is utterly redundant, but it may be helpful to you as an intermediate step.

like image 171
Mark Seemann Avatar answered Nov 15 '22 08:11

Mark Seemann


Jeffrey, can you please provide an example of what you are trying to do? I do not see your point, why/where/how you want to mix the 2 containers. If your code is entirely container-agnostic, then you won't have any problems to use either container for doing the wiring.

like image 38
Erich Eichinger Avatar answered Nov 15 '22 09:11

Erich Eichinger