Why should I prefer StructureMap over 开发者_高级运维Unity?
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.
精彩评论