6

Is it possible to pass a list constructor parameter when resolving a type? I want to use a programmatic configuration if possible. I've been playing around with the Parameters method as shown below, but I've not yet stumbled upon the answer.

container.Register(
    Component
    .For<IDoSomething>()
    .ImplementedBy<DoSomething>()
    .Parameters(...)
);

The DoSomething class would look something like this

public class DoSomething : IDoSomething
{
    public DoSomething(List<string> listOfStrings) 
    {
        ...
    }
}

1 Answer 1

6

Aha!

container.Register(
    Component
    .For<IDoSomething>()
    .ImplementedBy<DoSomething>()
    .Parameters(new { listOfStrings = someList })
);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.