The UserService constructor has two parameters: a IUnitOfWork and a IUserRepository :
public UserService(IUnitOfWork unitofWork, IUserRepository userRepository) { ... }
I use named registration to distinguish multiple instances of IUnitOfWork , so when registering a UserService with a Unity container, I need to explicitly specify using the InjectionConstructor :
container.RegisterType<IUserService, UserService>( new InjectionConstructor( new ResolvedParameter<IUnitOfWork>("someContext"), new ResolvedParameter<IUserRepository>() ) );
Is it possible to omit new ResolvedParameter<IUserRepository>() ? I would like Unity to implicitly output this parameter, since there is no need for the named registration. The code will look like this:
container.RegisterType<IUserService, UserService>( new InjectionConstructor( new ResolvedParameter<IUnitOfWork>("someContext") ) );
This will be done anyway when I do not need to use the InjectionConstructor .
source share