开发者

Why should I prefer StructureMap over Unity?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜