我正在尝试开始使用结构图。我使用的是 2.5.3 版。
我已经构建了一个简单的引导程序,但我无法编译它。我得到错误:
“StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression”不包含“WithCtorArg”的定义,并且没有扩展方法“WithCtorArg”接受“StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression”类型的第一个参数(你是缺少 using 指令或程序集引用?)
我错过了什么?
我尝试编译的代码在这里:
using DomainModel.Abstract;
using DomainModel.Concrete;
using StructureMap;
using StructureMap.Pipeline; //The only WithCtorArg methods I can find are in this namespace, it didn't help.
namespace WebUI
{
public class ContainerBootstrapper
{
public static void BootstrapStructureMap()
{
// Initialize the static ObjectFactory container
ObjectFactory.Initialize(x =>
{
x.ForRequestedType<IProductsRepository>()
.TheDefaultIsConcreteType<SqlProductsRepository>()
.WithCtorArg("connectionString")
.EqualToAppSetting("SqlConnection");
});
}
}
}