Are there any DI frameworks in the .Net world that is simple and which does not require too much meta-data configuration for eg. using xml etc?
A very good example from the Java world would be JBoss Weld. With Weld it is possible to have producer methods (methods that can be marked with custom annotation) that return objects. The objects produced above can be injected where needed. This saves a lot of meta-data configuration. Ofcourse Weld needs an xml too, but it does not mandate extensive configurations.
There's ninject lets you bind your types like this in code:
for contextual binding with ninject that uses attributes have a look at this
Create an attribute to decorate your class with
Bind the interface to the implementation with a given context
WhenClassHas
Decorate your class with the attribute.
here
StandardMountainWarrior
will be aSamurai
instead of aNinja
.Then there's TinyIOC which is even better it has autoregister :) or you can do:
And funq which lets you write clever delegates to resolve your types. which is really lacking documentation. But there's a nice vidcast.
and lots more of course. for example unity, structuremap and windsor which all have "in code" configuration.
I vote for NInject too. But almost any other IoC container for .NET now is code configurable. I did suggest to avoid using annotations, but prefer constructor injection instead. Annotation, or better attributes since we are in .NET world, makes your code coupled with the container, and this sounds like an antipattern since you use the container mainly for reduce code coupling.