配置Castle Windosor和通用 [英] configure Castle Windosor and generic

查看:41
本文介绍了配置Castle Windosor和通用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在Global.asax中的代码

this is my code in Global.asax

 WindsorContainer container = new WindsorContainer();
container.Register(Component.For(typeof(IRepository<>))
                                       .ImplementedBy(typeof(NHRepository<>))
                                       .LifeStyle.Transient)

我尝试以此将其转换为xml配置文件,但没有用

I've tried to translate it in a xml config file with this but didn't work

<component id="NHRepository"
           service="NCommon.Data.IRepository'1, NCommon"
           type="NCommon.Data.NHibernate.NHRepository'1, NCommon.NHibernate"
           lifestyle="transient">
</component>

如何在配置文件中将此代码转换为Windsor.config?

How can I convert this code in a config file as Windsor.config ?

坦克
Mirko

Tanks Mirko

推荐答案

您需要使用反引号,而不是撇号

<component id="NHRepository"
           service="NCommon.Data.IRepository`1, NCommon"
           type="NCommon.Data.NHibernate.NHRepository`1, NCommon.NHibernate"
           lifestyle="transient">
</component>

这篇关于配置Castle Windosor和通用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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