Code cleanup (bis)

This commit is contained in:
Geoffroy BONNEVILLE
2020-04-08 16:23:15 +02:00
parent d1047a92ba
commit 1046110dd2
5 changed files with 21 additions and 56 deletions

View File

@@ -23,6 +23,8 @@ namespace ModernKeePass.Infrastructure.KeePass
private readonly IDateTime _dateTime;
private readonly PwDatabase _pwDatabase = new PwDatabase();
private Credentials _credentials;
// Flag: Has Dispose already been called?
private bool _disposed;
public string ZeroId => PwUuid.Zero.ToHexString();
@@ -317,7 +319,22 @@ namespace ModernKeePass.Infrastructure.KeePass
public void Dispose()
{
if (IsOpen) CloseDatabase();
Dispose(true);
GC.SuppressFinalize(this);
}
// Protected implementation of Dispose pattern.
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_pwDatabase.Close();
}
_disposed = true;
}
}
}