gpt4 book ai didi

unity-container - 为什么我应该更喜欢 StructureMap 而不是 Unity?

转载 作者:行者123 更新时间:2023-12-04 07:11:07 25 4
gpt4 key购买 nike

为什么我应该更喜欢 StructureMap 而不是 Unity?

最佳答案

StructureMap 允许您按照约定注册您的类型。除了显式为 IFoo 注册 Foo、为 IBar 注册 Bar 和为 IBaz 注册 Baz,您可以这样做:

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

“默认约定”会自动注册每个具有同名接口(interface)和“I”前缀的类型。还有一些其他内置约定(如果您键入的命名不遵循此模式),定义您自己的约定很简单。

关于unity-container - 为什么我应该更喜欢 StructureMap 而不是 Unity?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3715906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com