使用StructureMap运行ObjectFactory.WhatDoIHave()时,查看同一依赖项的多个条目是否正常?例如,我看到了:
ISomeClass (Some.Namespace.ISomeClass) 8cddad2d-565b-4a6f-b487-f4ec0225335d Configured Instance of Another.Namespace.SomeClass, Some.Assembly, Version=4.5.0.15805, Culture=neutral, PublicKeyToken=null
Scoped as: Transient
5e015488-4f81-48c2-a6c2-4b94a66de76c Configured Instance of Another.Namespace.SomeClass, Some.Assembly, Version=4.5.0.15805, Culture=neutral, PublicKeyToken=null
5fb1a6d9-395a-42db-a226-5563d35ac8aa Configured Instance of Another.Namespace.SomeClass, Some.Assembly, Version=4.5.0.15805, Culture=neutral, PublicKeyToken=null
d431713f-dbdb-41c4-993f-d696433d805f Configured Instance of Another.Namespace.SomeClass, Some.Assembly, Version=4.5.0.15805, Culture=neutral, PublicKeyToken=null
1a14e0cf-52f2-4f7a-ac71-937fa5faade9 Configured Instance of Another.Namespace.SomeClass, Some.Assembly, Version=4.5.0.15805, Culture=neutral, PublicKeyToken=null
c6f638e7-824d-42e2-9a90-765921ae1da9 Configured Instance of Another.Namespace.SomeClass, Some.Assembly, Version=4.5.0.15805, Culture=neutral, PublicKeyToken=null
7627f1d5-23a7-4220-a400-d8a3509028f0 Configured Instance of Another.Namespace.SomeClass, Some.Assembly, Version=4.5.0.15805, Culture=neutral, PublicKeyToken=null
c693eae9-00a3-46e8-a6b1-923a82a5d87c Configured Instance of Another.Namespace.SomeClass, Some.Assembly, Version=4.5.0.15805, Culture=neutral, PublicKeyToken=null
看到这个是正常的吗?当我使用该系统时,条目数量继续增长。
注意:请记住,我在界面和具体类之间只有一对一的关系。我从来没有相同接口的多个实现。
答案 0 :(得分:2)
这对瞬态依赖关系来说是正常的。
瞬态意味着每次请求服务时都会创建一个新实例。