Injecting AutoMapper dependencies using Ninject

后端 未结 3 1989
我寻月下人不归
我寻月下人不归 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条回答
  •  执笔经年
    2021-02-08 11:25

    I got it working but it doesn't feel very clean creating an instance of the Configuration class. Any suggestions to clean it up further.

            Bind().To();
            Bind().ToConstant(new Configuration(Kernel.Get(), MapperRegistry.AllMappers())).InSingletonScope();
            Bind().ToMethod(c => c.Kernel.Get());
            Bind().ToMethod(c => c.Kernel.Get());
            Bind().To();
    

提交回复
热议问题