Cleanup code

This commit is contained in:
Geoffroy BONNEVILLE
2020-04-08 15:27:40 +02:00
parent 4863eb9fae
commit 009382ea03
27 changed files with 142 additions and 138 deletions

View File

@@ -34,6 +34,16 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>

View File

@@ -6,7 +6,6 @@ using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.Dtos;
using ModernKeePass.Domain.Entities;
using ModernKeePass.Domain.Enums;
using ModernKeePass.Domain.Exceptions;
using ModernKeePass.Domain.Interfaces;
using ModernKeePassLib;
using ModernKeePassLib.Cryptography.KeyDerivation;
@@ -126,6 +125,8 @@ namespace ModernKeePass.Infrastructure.KeePass
_pwDatabase.Name = name;
_pwDatabase.RootGroup.Name = name;
_credentials = credentials;
switch (version)
{
case DatabaseVersion.V4:
@@ -142,34 +143,20 @@ namespace ModernKeePass.Infrastructure.KeePass
public async Task<byte[]> SaveDatabase()
{
try
return await Task.Run(() =>
{
return await Task.Run(() =>
{
_pwDatabase.Save(new NullStatusLogger());
return _pwDatabase.IOConnectionInfo.Bytes;
});
}
catch (Exception e)
{
throw new SaveException(e);
}
_pwDatabase.Save(new NullStatusLogger());
return _pwDatabase.IOConnectionInfo.Bytes;
});
}
public async Task<byte[]> SaveDatabase(byte[] newFileContents)
{
try
return await Task.Run(() =>
{
return await Task.Run(() =>
{
_pwDatabase.SaveAs(IOConnectionInfo.FromByteArray(newFileContents), true, new NullStatusLogger());
return _pwDatabase.IOConnectionInfo.Bytes;
});
}
catch (Exception e)
{
throw new SaveException(e);
}
_pwDatabase.SaveAs(IOConnectionInfo.FromByteArray(newFileContents), true, new NullStatusLogger());
return _pwDatabase.IOConnectionInfo.Bytes;
});
}
public void CloseDatabase()

View File

@@ -1,7 +1,5 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage.AccessCache;
using ModernKeePass.Application.Common.Interfaces;