2010-01-18 79 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