views:

61

answers:

1

I have a hopefully simple question...

I am trying to change over from the XML registration to the Fluent Registration API, but am having one problem with registering objects that require an array as a constructor parameter.

For example

  <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>

How would I go about registering this with the fluent 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"})
                        ));
+2  A: 

IIRC it's something like this:

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

See the fluent registration wiki for more information.

Mauricio Scheffer
Perfect! I just realised that they recently updated the Fluent API documentation page... Thanks!
doobist
lol, recently means today :) And I'm glad it has already come in handy.
Krzysztof Koźmic