我希望能够解决一个可枚举的集合IRepository<T> where T : IDocument
在我的注册表类中,我添加了以下注册代码:
this.For<IRepository<IDocument>>().Add<Repository<Document>>();
this.For<IRepository<IDocument>>().Add<Repository<AnotherDocumentType>>();
类Document
和AnotherDocumentType
实现接口IDocument
,和Repository<T>
实现IRepository<T>
。我是结构图的新手,我不太了解错误消息。所有涉及的类都有默认构造函数。
Structuremap 抛出以下错误测试名称:can_resolve_a_collection_of_document_repositories 测试全名:my.test.IoCTest.can_resolve_a_collection_of_document_repositories 测试源:d:\Projects\level\my\mtrunk\src\my.test\IoCTest.cs:第 46 行测试结果:失败测试时间:0:00:00.138309
结果消息:测试方法 my.test.IoCTest.can_resolve_a_collection_of_document_repositories 抛出异常:StructureMap.Exceptions.StructureMapConfigurationException:StructureMap 配置失败:错误:104 源:注册表:StructureMap.Configuration.DSL.Registry,StructureMap,Version=2.6.4.0,Culture=中性,PublicKeyToken=e60ad81abae3c223 类型实例'613169b9-b8d9-4c80-868a-d6aa47e3d95c'(my.data.Impl.Repositories.Repository
1[[my.domain.Document, my.domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], my.data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null) cannot be plugged into type my.data.IRepository
1的配置实例[[my.domain.IDocument, my.domain, Version=1.0.0.0,文化=中性,PublicKeyToken=null]],my.data,版本=1.0.0.0,文化=中性,PublicKeyToken=null错误:104 来源:注册表:StructureMap.Configuration.DSL.Registry,StructureMap,Version=2.6.4.0,Culture=neutral,PublicKeyToken=e60ad81abae3c223 类型实例“2196350f-0c64-4bd2-92af-9946f1e11862”(my.data 的配置实例.Impl.Repositories.Repository
1[[my.domain.AnotherDocumentType, my.domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], my.data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null) cannot be plugged into type my.data.IRepository
1[[my.domain.IDocument, my.domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], my.data, Version=1.0.0.0, Culture=neutral, PublicKeyToken =空结果 StackTrace:在 StructureMap.Diagnostics.GraphLog.AssertFailures() 中 c:\BuildAgent\work\767273992e840853\src\StructureMap\Diagnostics\GraphLog.cs:第 68 行在 StructureMap.Container.construct(PluginGraph pluginGraph) 在 c:\BuildAgent \work\767273992e840853\src\StructureMap\Container.cs:第 576 行在 StructureMap.Container..ctor(PluginGraph pluginGraph) 在 c:\BuildAgent\work\767273992e840853\src\StructureMap\Container.cs:第 55 行在 StructureMap.ObjectFactory .Initialize(Action`1 action) in c:\BuildAgent\work\767273992e840853\src\StructureMap\ObjectFactory.cs:第 65 行 my.test.IoCTest.can_resolve_a_collection_of_document_repositories() in d:\Projects\level\my\mtrunk\ src\my.test\IoCTest.cs:第 51 行