mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Changed most services to singletons
Refactor the Database Service (no more enum, ...) Restored the Donate page with Paypal web page Added (but not working) MS App Center integration Corrected tests accordingly WIP AOP to detect database changes
This commit is contained in:
@@ -15,10 +15,10 @@ using ModernKeePassLib.Serialization;
|
||||
|
||||
namespace ModernKeePass.Services
|
||||
{
|
||||
public class DatabaseService: IDatabase
|
||||
public class DatabaseService: SingletonServiceBase<DatabaseService>, IDatabaseService
|
||||
{
|
||||
private readonly PwDatabase _pwDatabase = new PwDatabase();
|
||||
private readonly ISettings _settings;
|
||||
private readonly ISettingsService _settings;
|
||||
private StorageFile _realDatabaseFile;
|
||||
private StorageFile _databaseFile;
|
||||
private GroupVm _recycleBin;
|
||||
@@ -48,7 +48,7 @@ namespace ModernKeePass.Services
|
||||
get { return _databaseFile; }
|
||||
set
|
||||
{
|
||||
if (IsOpen)
|
||||
if (IsOpen && HasChanged)
|
||||
{
|
||||
throw new DatabaseOpenedException();
|
||||
}
|
||||
@@ -77,15 +77,18 @@ namespace ModernKeePass.Services
|
||||
public bool IsOpen => _pwDatabase.IsOpen;
|
||||
public bool IsFileOpen => !_pwDatabase.IsOpen && _databaseFile != null;
|
||||
public bool IsClosed => _databaseFile == null;
|
||||
public bool HasChanged { get; set; }
|
||||
|
||||
public DatabaseService() : this(SettingsService.Instance)
|
||||
{
|
||||
}
|
||||
|
||||
public DatabaseService() : this(new SettingsService())
|
||||
{ }
|
||||
|
||||
public DatabaseService(ISettings settings)
|
||||
public DatabaseService(ISettingsService settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Open a KeePass database
|
||||
/// </summary>
|
||||
@@ -118,7 +121,7 @@ namespace ModernKeePass.Services
|
||||
}
|
||||
else _pwDatabase.Open(ioConnection, key, new NullStatusLogger());
|
||||
|
||||
if (!_pwDatabase.IsOpen) return;
|
||||
//if (!_pwDatabase.IsOpen) return;
|
||||
|
||||
// Copy database in temp directory and use this file for operations
|
||||
if (_settings.GetSetting<bool>("AntiCorruption"))
|
||||
|
Reference in New Issue
Block a user