using Web API 2 with Unity IOC. I'm trying to figure out where can I register the types used across the whole solution.
In Asp.Net Web API all types registering is done in a class, called UnityConfig
public class UnityConfig
{
public static void Register(HttpConfiguration config)
{
var container= new UnityContainer();
container.RegisterType<IUsersService, UsersService>(); // BLL type
container.RegisterType<IRolesService, RolesService>(); // BLL type
container.RegisterType<IUnitOfWork, UnitOfWork>(); // DAL type
GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
}
}
which is then configured when the application first starts by the Global.asax.
PROBLEM IS - as long as its just the BLL services, everything is fine, application is supposed to be referencing BLL anyway.
but when DataAccessLayer repositories, which I also want to inject, come into play, this forces my main project, the "application layer" to have reference to the DAL project. a dependency which I don't want.
Where is my failure in the understanding of the concept ?