Fall back to default configuration if there is no configuration to be loaded.

develop
LEdoian 3 years ago
parent c9ce758cc6
commit 253b9cc87d

@ -11,8 +11,18 @@ namespace QuickPlay
sealed class AppConfiguration sealed class AppConfiguration
{ {
// XXX: All the fields need to be checked in overriden Equals method // XXX: All the fields need to be checked in overriden Equals method
public readonly string playerConfigUrl; // Also: sensible defaults should be provided in defaultConfiguration field
public string playerConfigUrl;
public static AppConfiguration loadConfiguration()
{
var cfg = loadSavedConfiguration();
if (cfg == null)
{
cfg = defaultConfiguration;
}
return cfg;
}
public static AppConfiguration loadSavedConfiguration() public static AppConfiguration loadSavedConfiguration()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -28,6 +38,10 @@ namespace QuickPlay
if (this != newConfig) throw new InvalidDataException("Saved configuration is different from the supplied one."); if (this != newConfig) throw new InvalidDataException("Saved configuration is different from the supplied one.");
} }
public static AppConfiguration defaultConfiguration = new AppConfiguration
{
playerConfigUrl = "file:///dev/null",
};
public PlayerConfiguration GetPlayerConfig() public PlayerConfiguration GetPlayerConfig()
{ {
// TODO: decide sensibly // TODO: decide sensibly

@ -35,7 +35,7 @@ namespace QuickPlay
// App initialization // App initialization
appConfig = AppConfiguration.loadSavedConfiguration(); appConfig = AppConfiguration.loadConfiguration();
currentPlayer = appConfig.GetPlayerConfig().GetPlayer(); currentPlayer = appConfig.GetPlayerConfig().GetPlayer();
// UI initialization // UI initialization

Loading…
Cancel
Save