I have a class like this:
public class MyClass
{
public MyClass(IService service)
{
this.Service = service;
this.Dependency = new Dependency(service);
}
}
I want to move the new Dependency()
call to the constructor.
public class MyClass
{
public MyClass(IService service, IDependency dependency)
{
this.Service = service;
this.Dependency = dependency;
}
}
I can't work out how to bind it so that the IDependency
is created with the service
constructor argument.
Bind<IDependency>()
.To<Dependency>()
.WithConstructorArgument("service", ctx => ctx.???); // How do I do this?