Add factory methods for UserConfig and AppConfig

This commit is contained in:
Ben Olden-Cooligan 2018-11-26 14:15:59 -05:00
parent e3a7d16002
commit 646edc205a
3 changed files with 8 additions and 4 deletions

View File

@ -17,8 +17,8 @@ namespace NAPS2.DI
Log.EventLogger = new WindowsEventLogger();
}
UserConfig.Manager = new ConfigManager<UserConfig>("config.xml", Paths.AppData, Paths.Executable, () => new UserConfig { Version = UserConfig.CURRENT_VERSION });
AppConfig.Manager = new ConfigManager<AppConfig>("appsettings.xml", Paths.Executable, null, () => new AppConfig { Version = AppConfig.CURRENT_VERSION });
UserConfig.Manager = new ConfigManager<UserConfig>("config.xml", Paths.AppData, Paths.Executable, UserConfig.Create);
AppConfig.Manager = new ConfigManager<AppConfig>("appsettings.xml", Paths.Executable, null, AppConfig.Create);
}
}
}

View File

@ -13,7 +13,7 @@ namespace NAPS2.Config
{
public const int CURRENT_VERSION = 2;
private static IConfigManager<AppConfig> _manager = new StubConfigManager<AppConfig>(new AppConfig { Version = CURRENT_VERSION });
private static IConfigManager<AppConfig> _manager = new StubConfigManager<AppConfig>(Create());
public static IConfigManager<AppConfig> Manager
{
@ -23,6 +23,8 @@ namespace NAPS2.Config
public static AppConfig Current => Manager.Config;
public static AppConfig Create() => new AppConfig { Version = CURRENT_VERSION };
public int Version { get; set; }
public string DefaultCulture { get; set; }

View File

@ -16,7 +16,7 @@ namespace NAPS2.Config
{
public const int CURRENT_VERSION = 2;
private static IConfigManager<UserConfig> _manager = new StubConfigManager<UserConfig>(new UserConfig { Version = CURRENT_VERSION });
private static IConfigManager<UserConfig> _manager = new StubConfigManager<UserConfig>(Create());
public static IConfigManager<UserConfig> Manager
{
@ -26,6 +26,8 @@ namespace NAPS2.Config
public static UserConfig Current => Manager.Config;
public static UserConfig Create() => new UserConfig { Version = CURRENT_VERSION };
public int Version { get; set; }
public string Culture { get; set; }