You can add another layer at the factory layerlevel:
public interface IUsers { ... }
public interface IFoo { ... }
public interface Factory {
IUsers GetUsers();
IFoo GetFoo();
}
public class MySQLFactory : Factory {
public IUsers GetUsers() {
return new MySQLUsers();
}
public IFoo GetFoo() {
return new MySQLFoo();
}
}
public class PostgresFactory : Factory {
public IUsers GetUsers() {
return new PostgresUsers();
}
public IFoo GetFoo() {
return new PostgresFoo();
}
}
public class DBFactory {
public static Factory getFactory(bool something) {
if(something) {
return new MySQLFactory();
}
else {
return new PostgresFactory();
}
}
}