显然,此方法不再被调用...在那里,我们有用于配置AutoMapper和设置模型绑定器的代码。
我知道有一种“新的”方式来做模型粘合剂,但是......在我实现之前,我不应该仍然能够“旧方式”吗?
具体来说,我的旧Application_Start()方法还剩下两行我无法正常工作:
AutoMapperConfiguration.Configure();
ModelBinders.Binders[typeof (ModuleEditModel)] = new DerivedModelBinder();
我尝试在调用之后立即将它们弹出到构造函数中:ServiceLocatorManager.SetLocatorProvider(()=> new StructureMapServiceLocator());
然后运行,但......似乎某种方式不能生效。在运行应用程序时,很明显AutoMapper不满意,没有它应该具有的映射等。
答案 0 :(得分:1)
我在Turbine Discussion board on CodePlex上回答了这个问题。以下是您要求进行更改的source:
public class MvcApplication : TurbineApplication {
static MvcApplication() {
// Register the IoC that you want Mvc Turbine to use!
// Everything else is wired automatically
// For now, let's use the Unity IoC
ServiceLocatorManager.SetLocatorProvider(() => new UnityServiceLocator());
}
public override void Startup(){
// Gets called when the application starts up
// and before all the stuff that Turbine wires up
}
public override void Shutdown() {
// Gets called when the application shuts down
// and before any cleanup is done by Turbine
}
}
希望这有帮助!