My Class Structure is:
public class PhotoService {
private IRepository _repo;
private DTConfig _config;
public PhotoService(IRepository repo, DTConfig config)
{
_repo = repo;
_config = config;
}
}
public class DTConfig
{
private int _accountId;
public DTConfig(int accountId)
{
_accountId = accountId;
}
}
My Ninject Bindings are like:
var kernel = new StandardKernel();
kernel.Bind<IPhotoService>().To<PhotoService>();
kernel.Bind<IRepository>().To<Repository>();
kernel.Bind<DTConfig>().ToSelf();
Now what I want, is to pass the accountId
as a parameter while creating an instance of PhotoService
var photo = kernel.Get<IPhotoService>();
How can I pass the parameter to DTConfig while creating an instance of PhotoService. The accountId is fetched from a service and is not available in compile time.
Feel free to comment if any other information is required.