I'm new to IOC containers, and I'm getting started with NInject.
What do you if you want your constructor to have parameters that are not services and don't need to be instantiated by the IOC container?
For example:
public class Person
{
private readonly string _name;
private readonly IPersonRepository _repository;
public Person(string name, IPersonRepository repository)
{
_name = name;
_repository = repository;
}
......
}
Imagine that name is a requirement of the Person class, so, to ensure that a Person always has a name, we require that it be passed in to the constructor.
How would we get an instance of Person using NInject? The name needs to be passed in by whichever bit of the app is creating a new Person, whilst the IOC container needs to pass in the IPersonRepository.
I understand that either the name or the repository could be injected using a property instead, but this would not be a clean solution - we are losing some of the programming language's semantic power.