Injecting AutoMapper dependencies using Ninject

后端 未结 3 1995
我寻月下人不归
我寻月下人不归 2021-02-08 10:37

I am having trouble injecting AutoMapper into an ASP.NET MVC 2 application using Ninject. I used Jimmy Bogard\'s post on AutoMapper and StructureMap type Configuration as a guid

3条回答
  •  猫巷女王i
    2021-02-08 11:20

    You can do this is a one liner using the latest version (currently 2.2.0).

    kernel.Rebind().ToMethod(context => Mapper.Engine);
    

    As an extra, I do agree with fodonnel, adding a facade to hide the Automapper interface is a good idea, however I wouldn't take the signatures directly from Automapper, unless you need all that functionality.

提交回复
热议问题