Hi. I am using Dependency Injection pattern to resolve correct instance of mine UnitOfWork. When I am using only one type mapping, all is ok
unityContainer.RegisterType<IUnitOfWork, UnitOfWork>();
The problem occurs when I am using two type mappings for the same interface:
unityContainer.RegisterType<IUnitOfWork, UnitOfWork1>();
unityContainer.RegisterType<IUnitOfWork, UnitOfWork2>();
I have very common code that making a call like
var unitOfWork = ServiceLocator.GetInstance<IUnitOfWork>();
In some cases it should return UnitOfWork, in some cases it should return UnitOfWork2.
How I resolve this problem without refactoring of common part?
P.S. And yes - I Know about named containers ))