按照惯例统一注册 - 未找到 MatchingInterface 属性
Unity Registration by convention - MatchingInterface property not found
我想在项目中使用 unity 的约定注册功能。因此,我遵循了 Microsoft 的 guide。不幸的是,我无法从 class WithMappings
中找到 属性 MatchingInterface
。我想使用这个 属性 因为我有多个 classes 和像 IFoo
和 Foo
.
这样的界面
有人解决了这个问题或有想法吗?
我的 unity 容器版本是 5.2.1.,刚从 NuGet 安装。
似乎方法 RegisterTypes()
的实现发生了变化。第二个参数需要一个函数委托,其中 returns 匹配某些条件的类型。在我的情况下 container.RegisterTypes(AllClasses.FromAssembliesInBasePath(), (c) => WithMappings.FromMatchingInterface(c));
解决了问题。
我想在项目中使用 unity 的约定注册功能。因此,我遵循了 Microsoft 的 guide。不幸的是,我无法从 class WithMappings
中找到 属性 MatchingInterface
。我想使用这个 属性 因为我有多个 classes 和像 IFoo
和 Foo
.
有人解决了这个问题或有想法吗?
我的 unity 容器版本是 5.2.1.,刚从 NuGet 安装。
似乎方法 RegisterTypes()
的实现发生了变化。第二个参数需要一个函数委托,其中 returns 匹配某些条件的类型。在我的情况下 container.RegisterTypes(AllClasses.FromAssembliesInBasePath(), (c) => WithMappings.FromMatchingInterface(c));
解决了问题。