2010-02-16 53 views
3

这是我在Global.asax中的代码配置城堡Windosor和通用

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

我试图把它与这个XML配置文件翻译,但没有奏效

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

如何我可以将此代码作为Windsor.config在配置文件中转换吗?

坦克 米尔科

+0

参见[此的其他问题(http://stackoverflow.com/questions/934352/castle-windsor-fluent- api-define-array-with-single-item-as-dependency) – Ahmad 2010-02-16 11:05:07

+0

不相关.... – 2010-02-16 13:07:51

回答

4

您需要使用backticks,不apostrophes

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

好的。我没有注意到它;) – 2010-02-16 14:01:26