I am a Java developer and I use Guice heavily. Now I'd like to learn C# but to my surprise I have not found an equivalent to Guice. I have just found tools like Ninject, Unity, StructureMap but I am looking more for a tool like Guice. I do not want to write down all my registrations manually... so what are the best options?
The one I like the most is Ninject. It has a plug-in to auto-register components based on conventions.
I am actually writing an open source library to auto-register components; it is designed to support most of the current IoC containers we have in .NET. This is the link in case you are interested: https://github.com/jupaol/NAutoRegister (check the Developer Branch).
With AutoFac you can register components easily as well.
I have checked out Guice and it's simply awesome. A good initiative would be to port Guice to .Net, just like many other Java tools.
I haven't used Guice, so if your talking about automatic registration of components, many IOC containers provide some sort of assembly scanning.
Have a look at the documentation for AutoFac, you can see its quite easy to register compontents.
var dataAccess = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(dataAccess)
.Where(t => t.Name.EndsWith("Repository"))
.AsImplementedInterfaces();
I've made a Guice port for C# with some of my favorite features. Fairly small code base, but has been used on over 50M devices via Unity3D, and probably more as I've just found out Disney is using it at the moment as well.
https://github.com/disturbing/suice
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With