I'm trying to avoid usage of Service Locator. The previous code looks like:
public class UnitOfWork
{
private T CreateRepository<T>(T repo)
where T :
IRepository
{
return ServiceLocator.Current.GetInstance<T>();
}
}
I am using Autofac as IoC. I dont wanna use
ILifetimeScopeor
IContainer` or similar. Can you please share your ideas on how to implement in an elegant way creating a generic method of creating repositories without a usage of Service Locator and an introduction of IoC dependencies?