0

显然,这个方法不再被调用......在那里我们有用于配置 AutoMapper 和设置模型绑定器的代码。

我知道有一种“新”的方式来做模型活页夹,但是......在我实现它之前,我不应该还能用“旧的方式”吗?

具体来说,我的旧 Application_Start() 方法留下了两行无法正常工作的内容:

        AutoMapperConfiguration.Configure();

        ModelBinders.Binders[typeof (ModuleEditModel)] = new DerivedModelBinder();

我试过简单地将它们弹出到构造函数中,在调用之后:ServiceLocatorManager.SetLocatorProvider(() => new StructureMapServiceLocator());

并且运行,但是..它似乎不知何故没有生效。在运行应用程序时,很明显 AutoMapper 不满意,没有它应该有的映射,等等。

4

1 回答 1

1

我在 CodePlex 的 Turbine Discussion board 上回答了这个问题。这是进行您要求的更改的来源:

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
    }
}

希望这可以帮助!

于 2010-07-14T19:19:32.283 回答