WIP Clean Architecture

Windows 8.1 App Uses keepasslib v2.44 (temporarily)
This commit is contained in:
Geoffroy BONNEVILLE
2020-03-24 13:01:14 +01:00
parent 34cd4ca3d8
commit 7e44d47065
290 changed files with 4084 additions and 36416 deletions

View File

@@ -0,0 +1,12 @@
using System.Collections.Generic;
using ModernKeePass.Domain.Entities;
namespace ModernKeePass.Application.Common.Interfaces
{
public interface ICryptographyClient
{
IEnumerable<BaseEntity> Ciphers { get; }
IEnumerable<BaseEntity> KeyDerivations { get; }
IEnumerable<string> CompressionAlgorithms { get; }
}
}

View File

@@ -0,0 +1,28 @@
using System.Threading.Tasks;
using ModernKeePass.Domain.Dtos;
using ModernKeePass.Domain.Entities;
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IDatabaseProxy
{
bool IsOpen { get; }
GroupEntity RecycleBin { get; set; }
BaseEntity Cipher { get; set; }
BaseEntity KeyDerivation { get; set; }
string Compression { get; set; }
Task<DatabaseEntity> Open(FileInfo fileInfo, Credentials credentials);
Task<DatabaseEntity> Create(FileInfo fileInfo, Credentials credentials);
Task SaveDatabase();
Task SaveDatabase(FileInfo FileInfo);
Task UpdateCredentials(Credentials credentials);
void CloseDatabase();
Task AddEntry(GroupEntity parentGroup, EntryEntity entity);
Task AddGroup(GroupEntity parentGroup, GroupEntity entity);
Task UpdateEntry(EntryEntity entity);
Task UpdateGroup(GroupEntity entity);
Task DeleteEntry(EntryEntity entity);
Task DeleteGroup(GroupEntity entity);
}
}

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IFileProxy
{
Task<byte[]> OpenBinaryFile(string path);
Task<IList<string>> OpenTextFile(string path);
Task WriteBinaryContentsToFile(string path, byte[] contents);
void ReleaseFile(string path);
}
}

View File

@@ -0,0 +1,7 @@
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IHasSelectableObject
{
ISelectableModel SelectedItem { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IImportFormat
{
Task<List<Dictionary<string, string>>> Import(string path);
}
}

View File

@@ -0,0 +1,7 @@
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IIsEnabled
{
bool IsEnabled { get; }
}
}

View File

@@ -0,0 +1,11 @@
using ModernKeePass.Domain.Dtos;
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IPasswordProxy
{
string GeneratePassword(PasswordGenerationOptions options);
uint EstimatePasswordComplexity(string password);
byte[] GenerateKeyFile(byte[] additionalEntropy);
}
}

View File

@@ -0,0 +1,9 @@
using System.Reflection;
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IProxyInvocationHandler
{
object Invoke(object proxy, MethodInfo method, object[] parameters);
}
}

View File

@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using ModernKeePass.Domain.Dtos;
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IRecentProxy
{
int EntryCount { get; }
Task<FileInfo> Get(string token);
Task<IEnumerable<FileInfo>> GetAll();
Task Add(FileInfo recentItem);
void ClearAll();
}
}

View File

@@ -0,0 +1,7 @@
namespace ModernKeePass.Application.Common.Interfaces
{
public interface IResourceProxy
{
string GetResourceValue(string key);
}
}

View File

@@ -0,0 +1,7 @@
namespace ModernKeePass.Application.Common.Interfaces
{
public interface ISelectableModel
{
bool IsSelected { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace ModernKeePass.Application.Common.Interfaces
{
public interface ISettingsProxy
{
T GetSetting<T>(string property, T defaultValue = default);
void PutSetting<T>(string property, T value);
}
}

View File

@@ -0,0 +1,10 @@
using AutoMapper;
namespace ModernKeePass.Application.Common.Mappings
{
public interface IMapFrom<T>
{
void Mapping(Profile profile);
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Linq;
using System.Reflection;
using AutoMapper;
namespace ModernKeePass.Application.Common.Mappings
{
public class MappingProfile : Profile
{
public MappingProfile()
{
ApplyMappingsFromAssembly(Assembly.GetExecutingAssembly());
}
private void ApplyMappingsFromAssembly(Assembly assembly)
{
var types = assembly.GetExportedTypes()
.Where(t => t.GetInterfaces().Any(i =>
i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IMapFrom<>)))
.ToList();
foreach (var type in types)
{
var instance = Activator.CreateInstance(type);
var methodInfo = type.GetMethod("Mapping");
methodInfo?.Invoke(instance, new object[] { this });
}
}
}
}

View File

@@ -0,0 +1,17 @@
using AutoMapper;
using ModernKeePass.Application.Database.Models;
using ModernKeePass.Application.Entry.Models;
using ModernKeePass.Application.Group.Models;
namespace ModernKeePass.Application.Common.Mappings
{
public class MappingProfiles: Profile
{
public void ApplyMappings()
{
new DatabaseVm().Mapping(this);
new EntryVm().Mapping(this);
new GroupVm().Mapping(this);
}
}
}