mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
WIP Clean Architecture
Windows 8.1 App Uses keepasslib v2.44 (temporarily)
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
13
ModernKeePass.Application/Common/Interfaces/IFileProxy.cs
Normal file
13
ModernKeePass.Application/Common/Interfaces/IFileProxy.cs
Normal 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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface IHasSelectableObject
|
||||
{
|
||||
ISelectableModel SelectedItem { get; set; }
|
||||
}
|
||||
}
|
10
ModernKeePass.Application/Common/Interfaces/IImportFormat.cs
Normal file
10
ModernKeePass.Application/Common/Interfaces/IImportFormat.cs
Normal 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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface IIsEnabled
|
||||
{
|
||||
bool IsEnabled { get; }
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface IProxyInvocationHandler
|
||||
{
|
||||
object Invoke(object proxy, MethodInfo method, object[] parameters);
|
||||
}
|
||||
}
|
15
ModernKeePass.Application/Common/Interfaces/IRecentProxy.cs
Normal file
15
ModernKeePass.Application/Common/Interfaces/IRecentProxy.cs
Normal 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface IResourceProxy
|
||||
{
|
||||
string GetResourceValue(string key);
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface ISelectableModel
|
||||
{
|
||||
bool IsSelected { get; set; }
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
10
ModernKeePass.Application/Common/Mappings/IMapFrom.cs
Normal file
10
ModernKeePass.Application/Common/Mappings/IMapFrom.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace ModernKeePass.Application.Common.Mappings
|
||||
{
|
||||
|
||||
public interface IMapFrom<T>
|
||||
{
|
||||
void Mapping(Profile profile);
|
||||
}
|
||||
}
|
30
ModernKeePass.Application/Common/Mappings/MappingProfile.cs
Normal file
30
ModernKeePass.Application/Common/Mappings/MappingProfile.cs
Normal 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
ModernKeePass.Application/Common/Mappings/MappingProfiles.cs
Normal file
17
ModernKeePass.Application/Common/Mappings/MappingProfiles.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user