I have a service layer in my application which contains services such as AccountService
, UserService
and DocumentService
.
I use StructureMap for my dependency injection so the constructor of my service might look like this:
public AccountService(IAccountRepository repo)
{
this.accountRepository = repo;
}
Now if I need access to say the UserServic
e whilst in there is it good form to have the following?
public AccountService(IAccountRepository repo, IUserService user)
{
this.accountRepository = repo;
this.userService = user;
}
Yes, it perfectly fine. You can download the code and watch the episodes Rob Conery prepared.
He injects the OrderService in the CatalogService.