3

Why should I prefer StructureMap over Unity?

Saghar
  • 693
  • 2
  • 12
  • 24
  • possible duplicate of [which one is better structure map or unity application block](http://stackoverflow.com/questions/1398486/which-one-is-better-structure-map-or-unity-application-block) – M4N Sep 15 '10 at 08:34
  • Its not a duplicate. If u look the answer there it has just one reference (http://stackoverflow.com/questions/21288/which-c-net-dependency-injection-frameworks-are-worth-looking-into) and thats all. Its not a specific to StructureMap and Unity. – Saghar Sep 15 '10 at 08:57
  • It's still a duplicate (IMO). But unfortunately there were no good answers, except the link to yet another question. – M4N Sep 15 '10 at 09:17
  • 2
    Don't choose StructureMap if you want any up-to-date documentation. It is fairly non-existent. – nportelli Mar 15 '12 at 20:44

1 Answers1

5

StructureMap allows you to register your types by convention. Instead of explicitly registering Foo for IFoo, Bar for IBar, and Baz for IBaz, you can do:

ObjectFactory.Initialize(x => 
  x.Scan(scan => {
    scan.TheCurrentAssembly();
    scan.WithDefaultConventions();
  })
);

The "default convention" automatically registers every type that has an interface with the same name and the "I" prefix. There are a few other built-in conventions (if you type naming doesn't follow this pattern), and it is trivial to define your own.

Joshua Flanagan
  • 8,527
  • 2
  • 31
  • 40
  • 1
    No, it was just one of the more compelling reasons that most people would find useful. It is also much more mature than Unity. There are a number of features that Unity does not have, but repeating them all here would be like repeating the documentation. Hopefully a link will do http://structuremap.github.com/structuremap/ – Joshua Flanagan Sep 15 '10 at 21:53