mirror of
https://github.com/cyanfish/naps2.git
synced 2024-11-13 06:27:11 +03:00
Default to in-memory AppConfig and UserConfig
This commit is contained in:
parent
2b1dc944f3
commit
e3a7d16002
@ -76,11 +76,7 @@ namespace NAPS2.DI.Modules
|
||||
Bind<IBlankDetector>().To<ThresholdBlankDetector>();
|
||||
Bind<IAutoSave>().To<AutoSave>();
|
||||
|
||||
Log.Logger = new NLogLogger();
|
||||
if (PlatformCompat.System.CanUseWin32)
|
||||
{
|
||||
Log.EventLogger = Kernel.Get<WindowsEventLogger>();
|
||||
}
|
||||
StaticConfiguration.Initialize();
|
||||
#if DEBUG
|
||||
Debug.Listeners.Add(new NLogTraceListener());
|
||||
#endif
|
||||
|
@ -94,6 +94,7 @@
|
||||
<Compile Include="NLogLogger.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="EntryPoints\WinFormsEntryPoint.cs" />
|
||||
<Compile Include="StaticConfiguration.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
24
NAPS2.Lib.Common/StaticConfiguration.cs
Normal file
24
NAPS2.Lib.Common/StaticConfiguration.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NAPS2.Config;
|
||||
using NAPS2.Logging;
|
||||
using NAPS2.Platform;
|
||||
|
||||
namespace NAPS2.DI
|
||||
{
|
||||
public static class StaticConfiguration
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Log.Logger = new NLogLogger();
|
||||
if (PlatformCompat.System.CanUseWin32)
|
||||
{
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ namespace NAPS2.Config
|
||||
{
|
||||
public const int CURRENT_VERSION = 2;
|
||||
|
||||
private static IConfigManager<AppConfig> _manager = new ConfigManager<AppConfig>("appsettings.xml", Paths.Executable, null, () => new AppConfig { Version = CURRENT_VERSION });
|
||||
private static IConfigManager<AppConfig> _manager = new StubConfigManager<AppConfig>(new AppConfig { Version = CURRENT_VERSION });
|
||||
|
||||
public static IConfigManager<AppConfig> Manager
|
||||
{
|
||||
@ -76,14 +76,14 @@ namespace NAPS2.Config
|
||||
public double OcrTimeoutInSeconds { get; set; }
|
||||
|
||||
public OcrState OcrState { get; set; }
|
||||
|
||||
|
||||
public string OcrDefaultLanguage { get; set; }
|
||||
|
||||
public OcrMode OcrDefaultMode { get; set; }
|
||||
|
||||
public bool OcrDefaultAfterScanning { get; set; }
|
||||
|
||||
public PdfCompat ForcePdfCompat { get; set; }
|
||||
public PdfCompat ForcePdfCompat { get; set; }
|
||||
|
||||
public EventType EventLogging { get; set; }
|
||||
|
||||
|
24
NAPS2.Sdk/Config/StubConfigManager.cs
Normal file
24
NAPS2.Sdk/Config/StubConfigManager.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NAPS2.Config
|
||||
{
|
||||
public class StubConfigManager<T> : IConfigManager<T>
|
||||
{
|
||||
public StubConfigManager(T config)
|
||||
{
|
||||
Config = config;
|
||||
}
|
||||
|
||||
public T Config { get; }
|
||||
|
||||
public void Load()
|
||||
{
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace NAPS2.Config
|
||||
{
|
||||
public const int CURRENT_VERSION = 2;
|
||||
|
||||
private static IConfigManager<UserConfig> _manager = new ConfigManager<UserConfig>("config.xml", Paths.AppData, Paths.Executable, () => new UserConfig { Version = CURRENT_VERSION });
|
||||
private static IConfigManager<UserConfig> _manager = new StubConfigManager<UserConfig>(new UserConfig { Version = CURRENT_VERSION });
|
||||
|
||||
public static IConfigManager<UserConfig> Manager
|
||||
{
|
||||
|
@ -157,6 +157,7 @@
|
||||
<Compile Include="ClientServer\ScanCallback.cs" />
|
||||
<Compile Include="ClientServer\ScanService.cs" />
|
||||
<Compile Include="ClientServer\ServerDiscovery.cs" />
|
||||
<Compile Include="Config\StubConfigManager.cs" />
|
||||
<Compile Include="Dependencies\ComponentManager.cs" />
|
||||
<Compile Include="Dependencies\DownloadMirror.cs" />
|
||||
<Compile Include="Dependencies\MultiFileExternalComponent.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user