Reputation: 13805
Using Ninject, how can I bind using a constructor that accepts a parameter.
I see how I can do this:
kernel.Bind(Of IWidget).To(Of Widget)
But, what if Widget has a constructor that takes a string? Is there a way to bind this way:
kernel.Bind(Of IWidget).To(Of Widget(myParam))
Upvotes: 0
Views: 179
Reputation: 7804
I believe .WithConstructorArgument
will suffice for your need:
Bind(Of IWidget).To(Of Widget)
.WithConstructorArgument("constructorArgumentOne", ...)
Upvotes: 1