views:

52

answers:

1

Why should I prefer StructureMap over Unity?

+2  A: 

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
Is it the only reason?
Saghar
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
Thanks Joshua Flanagan.
Saghar