2010-01-18 80 views
0

我有一个希望简单的问题,一个参数的对象...注册,有一个字符串数组作为使用温莎城堡流利的注册API

我试图从XML注册到流利注册API在发生变化,但在注册需要数组作为构造函数参数的对象时遇到了一个问题。

例如

<component id="Example" lifestyle="transient" 
    service="Test, Example.Test" 
    type="Test, Example.Test"> 
    <parameters> 
     <C> 
     <array> 
      <item>Value One</item> 
      <item>Value Two</item> 
     </array> 
     </C> 
    </parameters> 
    </component> 

我怎么会去用流利的API注册呢?

//the constructor for test is Test(string[] C){} 

_container.Register(Component.For<Test>().ImplementedBy<Test>().Parameters(
         Parameter 
         .ForKey("C") 
         .Eq(new string[]{"Value one","Value two"}) 
         )); 
+0

顺便说一句if service == type你不需要ImplementedBy – 2010-01-18 21:56:27

回答

3

IIRC它是这样的:

_container.Register(Component.For<Test>().ImplementedBy<Test>().DependsOn(
        Property 
        .ForKey("C") 
        .Eq(new string[]{"Value one","Value two"}) 
        )); 

更多信息,请参见fluent registration wiki

+0

完美!我刚刚意识到他们最近更新了Fluent API文档页面......谢谢! – doobist 2010-01-18 17:32:53

+0

大声笑,最近意味着今天:)我很高兴它已经派上用场了。 – 2010-01-18 21:32:23