views:

48

answers:

4

Dependency injection looks great, however when I look at examples I often see lots of XML config file. This is not good because:

  • I don’t get compile time checking on the type names in the config files
  • Refactoring tools don’t update the confilg files when types are renamed
  • I don’t want the customers changing the configuration!
  • I am a C# programmer, and would rather not hide the logic of my application in XML.

Some frameworks will let you config them from code, however most of their documentation (and examples) assumes you are using XML, as the XML config came first. So what dependency injection frameworks consider code based configuration to be the normal way of using them?

A: 

Ninject

anthony
+2  A: 

AutoFac
Ninject

Carl Bergquist
+2  A: 

Almost all containers now have a code based API for registering dependencies, even those which were originally configured only via XML. And usually the XML approach is only recommended for edge-cases (e.g. where there maybe a need to change registration / wiring post-deployment)

Eg StructureMap and Castle Windsor

martinl
A: 

Simple Service Locator (shameless plug)

Steven