I have the following problem - I write the code for object data manager, and one of requirements is being able to save/load data into some persistent data storage. I want to make it as the following:
- there is an interface, IPersistentDataService.
- if user uses an option to save/load from file, they can give arbitrary filename and save/load data.
- if user uses an option to save to database/load from database, they set database connection parameters once (server, database, username, password, trusted connection etc), and then proceed to save/load from database
- if user uses an option to save/load using API, they give api address and credentials.
I have the trouble setting one consistent interface for all the cases. Of course I can make something like:
public interface IPersistentStorage{
void Save(IDatabase database);
IDatabase Load();
}
but then I cannot use arbitrary filename given by user when saving/loading from file - it has to be set when building IPersistentStorage
object.