I\'m still a newbie at DI, and I am trying to understand if I am thinking of things the wrong way. I am working on a toy problem when I want to represent a Die object that has
You could use ConstructorArgument
together with Kernel.Get
in this particular situation.
Here is full sample.
public class ExampleKernel : NinjectModule
{
public override void Load()
{
Bind()
.To();
Bind()
.ToSelf()
.WithConstructorArgument("numSides", 6);
// default value for numSides
}
}
var d6 = kernel.Get(); // default numSides value
var d20 = kernel.Get(new ConstructorArgument("numSides", 20)); // custom numSides
Assert.That(d6.NumSides == 6);
Assert.That(d20.NumSides == 20);