You could approach this differently. Since both repositories and the unit of work is specified in an abstract way (with interfaces), your concrete implementation of the unit of work should create concrete instances of repositories:
public class EntityFrameworkUnitOfWork : IUnitOfWork
{
private readonly MyContext context;
private IGenericRepository<User> _userRepository
public IGenericRepository<User> UserRepository
{
get
{
if ( _userRepository == null )
_userRepository = new EntityFrameworkUserRepository( this.context );
return _userRepository;
}
}
public UnitOfWork(MyContext cont)
{
this.cotnext = cont;
}
}
public class AnotherConcreteUnitOfWork : IUnitOfWork
{
private readonly Something some;
private readonly Another dependency;
private IGenericRepository<User> _userRepository
public IGenericRepository<User> UserRepository
{
get
{
if ( _userRepository == null )
_userRepository = new AnotherConcreteUserRepository( some, dependency );
return _userRepository;
}
}
public UnitOfWork(Something some, Another dependency)
{
this.some = some;
this.dependency = dependency;
}
}
so that when you switch between implementations, you specify only the concrete type for the unit of work:
kernel.Bind<IUnitOfWork>().To<EntityFrameworkUnitOfWork>();
or
kernel.Bind<IUnitOfWork>().To<AnotherConcreteUnitOfWork>();
Note that having a concrete unit of work for concrete set of repositories makes it easier to deal with external dependencies you have to inject first to the unit of work and from there, to repositories (in the example above, there entity framework unit of work depends on the dbcontext while the other unit of work depends on other objects).