如何配置Automapper与Ninject 2.0注入? [英] How to configure Automapper to be injected with Ninject 2.0?

查看:112
本文介绍了如何配置Automapper与Ninject 2.0注入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有对结构图和温莎配置的例子: 的http://www.cprieto.com/index.php/2009/08/20/using-automapper-with-castle-windsor/

不过,我还没有发现任何东西Ninject。

你知道如何将这些映射转换为Ninject?

解决方案

 公共类AutoMapperModule:NinjectModule
{
    公众覆盖无效负载()
    {
        绑定< IMappingEngine>()ToMethod(CTX => Mapper.Engine);
    }
}
 

There are configuration examples for Structure Map and Windsor: http://www.cprieto.com/index.php/2009/08/20/using-automapper-with-castle-windsor/

But I haven't found anything for Ninject.

Do you know how to translate those mappings to Ninject?

解决方案

public class AutoMapperModule : NinjectModule
{
    public override void Load()
    {
        Bind<IMappingEngine>().ToMethod(ctx => Mapper.Engine);
    }
}

这篇关于如何配置Automapper与Ninject 2.0注入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆