diff --git a/ModernKeePass.Application.12/Common/Interfaces/ICryptographyClient.cs b/ModernKeePass.Application.12/Common/Interfaces/ICryptographyClient.cs deleted file mode 100644 index f7c19ff..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/ICryptographyClient.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; -using ModernKeePass.Domain.Entities; - -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface ICryptographyClient - { - IEnumerable Ciphers { get; } - IEnumerable KeyDerivations { get; } - IEnumerable CompressionAlgorithms { get; } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/IDatabaseProxy.cs b/ModernKeePass.Application.12/Common/Interfaces/IDatabaseProxy.cs deleted file mode 100644 index de508b7..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IDatabaseProxy.cs +++ /dev/null @@ -1,28 +0,0 @@ -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 Open(FileInfo fileInfo, Credentials credentials); - Task 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); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/IFileProxy.cs b/ModernKeePass.Application.12/Common/Interfaces/IFileProxy.cs deleted file mode 100644 index e9870e2..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IFileProxy.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface IFileProxy - { - Task OpenBinaryFile(string path); - Task> OpenTextFile(string path); - Task WriteBinaryContentsToFile(string path, byte[] contents); - void ReleaseFile(string path); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/IHasSelectableObject.cs b/ModernKeePass.Application.12/Common/Interfaces/IHasSelectableObject.cs deleted file mode 100644 index f2fd247..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IHasSelectableObject.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface IHasSelectableObject - { - ISelectableModel SelectedItem { get; set; } - } -} diff --git a/ModernKeePass.Application.12/Common/Interfaces/IImportFormat.cs b/ModernKeePass.Application.12/Common/Interfaces/IImportFormat.cs deleted file mode 100644 index f581762..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IImportFormat.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface IImportFormat - { - Task>> Import(string path); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/IIsEnabled.cs b/ModernKeePass.Application.12/Common/Interfaces/IIsEnabled.cs deleted file mode 100644 index 1abc45a..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IIsEnabled.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface IIsEnabled - { - bool IsEnabled { get; } - } -} diff --git a/ModernKeePass.Application.12/Common/Interfaces/IPasswordProxy.cs b/ModernKeePass.Application.12/Common/Interfaces/IPasswordProxy.cs deleted file mode 100644 index aec2b37..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IPasswordProxy.cs +++ /dev/null @@ -1,11 +0,0 @@ -using ModernKeePass.Domain.Dtos; - -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface IPasswordProxy - { - string GeneratePassword(PasswordGenerationOptions options); - uint EstimatePasswordComplexity(string password); - byte[] GenerateKeyFile(byte[] additionalEntropy); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/IProxyInvocationHandler.cs b/ModernKeePass.Application.12/Common/Interfaces/IProxyInvocationHandler.cs deleted file mode 100644 index 5a04d1f..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IProxyInvocationHandler.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Reflection; - -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface IProxyInvocationHandler - { - object Invoke(object proxy, MethodInfo method, object[] parameters); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/IRecentProxy.cs b/ModernKeePass.Application.12/Common/Interfaces/IRecentProxy.cs deleted file mode 100644 index f0792ab..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IRecentProxy.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using ModernKeePass.Domain.Dtos; - -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface IRecentProxy - { - int EntryCount { get; } - Task Get(string token); - Task> GetAll(); - Task Add(FileInfo recentItem); - void ClearAll(); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/IResourceProxy.cs b/ModernKeePass.Application.12/Common/Interfaces/IResourceProxy.cs deleted file mode 100644 index ba1530c..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/IResourceProxy.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface IResourceProxy - { - string GetResourceValue(string key); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/ISelectableModel.cs b/ModernKeePass.Application.12/Common/Interfaces/ISelectableModel.cs deleted file mode 100644 index 1102637..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/ISelectableModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface ISelectableModel - { - bool IsSelected { get; set; } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Interfaces/ISettingsProxy.cs b/ModernKeePass.Application.12/Common/Interfaces/ISettingsProxy.cs deleted file mode 100644 index 6471175..0000000 --- a/ModernKeePass.Application.12/Common/Interfaces/ISettingsProxy.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ModernKeePass.Application.Common.Interfaces -{ - public interface ISettingsProxy - { - T GetSetting(string property, T defaultValue = default); - void PutSetting(string property, T value); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Mappings/IMapFrom.cs b/ModernKeePass.Application.12/Common/Mappings/IMapFrom.cs deleted file mode 100644 index da4ab61..0000000 --- a/ModernKeePass.Application.12/Common/Mappings/IMapFrom.cs +++ /dev/null @@ -1,10 +0,0 @@ -using AutoMapper; - -namespace ModernKeePass.Application.Common.Mappings -{ - - public interface IMapFrom - { - void Mapping(Profile profile); - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Mappings/MappingProfile.cs b/ModernKeePass.Application.12/Common/Mappings/MappingProfile.cs deleted file mode 100644 index c572745..0000000 --- a/ModernKeePass.Application.12/Common/Mappings/MappingProfile.cs +++ /dev/null @@ -1,30 +0,0 @@ -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 }); - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Common/Mappings/MappingProfiles.cs b/ModernKeePass.Application.12/Common/Mappings/MappingProfiles.cs deleted file mode 100644 index dbd055d..0000000 --- a/ModernKeePass.Application.12/Common/Mappings/MappingProfiles.cs +++ /dev/null @@ -1,17 +0,0 @@ -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); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Database/Commands/CloseDatabase/CloseDatabaseCommand.cs b/ModernKeePass.Application.12/Database/Commands/CloseDatabase/CloseDatabaseCommand.cs deleted file mode 100644 index 904641e..0000000 --- a/ModernKeePass.Application.12/Database/Commands/CloseDatabase/CloseDatabaseCommand.cs +++ /dev/null @@ -1,31 +0,0 @@ -using MediatR; -using System.Threading; -using System.Threading.Tasks; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Application.Database.Queries.IsDatabaseOpen; -using ModernKeePass.Domain.Exceptions; - -namespace ModernKeePass.Application.Database.Commands.CloseDatabase -{ - public class CloseDatabaseCommand: IRequest - { - public class CloseDatabaseCommandHandler : IRequestHandler - { - private readonly IDatabaseProxy _database; - private readonly IMediator _mediator; - - public CloseDatabaseCommandHandler(IDatabaseProxy database, IMediator mediator) - { - _database = database; - _mediator = mediator; - } - - public async Task Handle(CloseDatabaseCommand message, CancellationToken cancellationToken) - { - var isDatabaseOpen = await _mediator.Send(new IsDatabaseOpenQuery(), cancellationToken); - if (isDatabaseOpen) _database.CloseDatabase(); - else throw new DatabaseClosedException(); - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Database/Commands/CreateDatabase/CreateDatabaseCommand.cs b/ModernKeePass.Application.12/Database/Commands/CreateDatabase/CreateDatabaseCommand.cs deleted file mode 100644 index e0e7c44..0000000 --- a/ModernKeePass.Application.12/Database/Commands/CreateDatabase/CreateDatabaseCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -using MediatR; -using System.Threading; -using System.Threading.Tasks; -using AutoMapper; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Application.Database.Models; -using ModernKeePass.Application.Database.Queries.IsDatabaseOpen; -using ModernKeePass.Application.Group.Models; -using ModernKeePass.Domain.Dtos; -using ModernKeePass.Domain.Exceptions; - -namespace ModernKeePass.Application.Database.Commands.CreateDatabase -{ - public class CreateDatabaseCommand : IRequest - { - public FileInfo FileInfo { get; set; } - public Credentials Credentials { get; set; } - - public class CreateDatabaseCommandHandler : IRequestHandler - { - private readonly IDatabaseProxy _database; - private readonly IMediator _mediator; - private readonly IMapper _mapper; - - public CreateDatabaseCommandHandler(IDatabaseProxy database, IMediator mediator, IMapper mapper) - { - _database = database; - _mediator = mediator; - _mapper = mapper; - } - - public async Task Handle(CreateDatabaseCommand message, CancellationToken cancellationToken) - { - var isDatabaseOpen = await _mediator.Send(new IsDatabaseOpenQuery(), cancellationToken); - if (isDatabaseOpen) throw new DatabaseOpenException(); - - var database = await _database.Create(message.FileInfo, message.Credentials); - var databaseVm = new DatabaseVm - { - IsOpen = true, - Name = database.Name, - RootGroup = _mapper.Map(database.RootGroupEntity) - }; - return databaseVm; - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Database/Commands/SaveDatabase/SaveDatabaseCommand.cs b/ModernKeePass.Application.12/Database/Commands/SaveDatabase/SaveDatabaseCommand.cs deleted file mode 100644 index 3d29159..0000000 --- a/ModernKeePass.Application.12/Database/Commands/SaveDatabase/SaveDatabaseCommand.cs +++ /dev/null @@ -1,31 +0,0 @@ -using MediatR; -using System.Threading; -using System.Threading.Tasks; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Application.Database.Queries.IsDatabaseOpen; -using ModernKeePass.Domain.Exceptions; - -namespace ModernKeePass.Application.Database.Commands.SaveDatabase -{ - public class SaveDatabaseCommand : IRequest - { - public class SaveDatabaseCommandHandler : IRequestHandler - { - private readonly IDatabaseProxy _database; - private readonly IMediator _mediator; - - public SaveDatabaseCommandHandler(IDatabaseProxy database, IMediator mediator) - { - _database = database; - _mediator = mediator; - } - - public async Task Handle(SaveDatabaseCommand message, CancellationToken cancellationToken) - { - var isDatabaseOpen = await _mediator.Send(new IsDatabaseOpenQuery(), cancellationToken); - if (isDatabaseOpen) await _database.SaveDatabase(); - else throw new DatabaseClosedException(); - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Database/Models/DatabaseVm.cs b/ModernKeePass.Application.12/Database/Models/DatabaseVm.cs deleted file mode 100644 index bc7cbde..0000000 --- a/ModernKeePass.Application.12/Database/Models/DatabaseVm.cs +++ /dev/null @@ -1,21 +0,0 @@ -using AutoMapper; -using ModernKeePass.Application.Common.Mappings; -using ModernKeePass.Application.Group.Models; -using ModernKeePass.Domain.Entities; - -namespace ModernKeePass.Application.Database.Models -{ - public class DatabaseVm: IMapFrom - { - public bool IsOpen { get; set; } - public string Name { get; set; } - public GroupVm RootGroup { get; set; } - - public void Mapping(Profile profile) - { - profile.CreateMap() - .ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name)) - .ForMember(d => d.RootGroup, opts => opts.MapFrom(s => s.RootGroupEntity)); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Database/Models/MainVm.cs b/ModernKeePass.Application.12/Database/Models/MainVm.cs deleted file mode 100644 index e13bb27..0000000 --- a/ModernKeePass.Application.12/Database/Models/MainVm.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace ModernKeePass.Application.Database.Models -{ - public class MainVm - { - - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Database/Queries/IsDatabaseOpen/IsDatabaseOpenQuery.cs b/ModernKeePass.Application.12/Database/Queries/IsDatabaseOpen/IsDatabaseOpenQuery.cs deleted file mode 100644 index 0266666..0000000 --- a/ModernKeePass.Application.12/Database/Queries/IsDatabaseOpen/IsDatabaseOpenQuery.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using MediatR; -using ModernKeePass.Application.Common.Interfaces; - -namespace ModernKeePass.Application.Database.Queries.IsDatabaseOpen -{ - public class IsDatabaseOpenQuery: IRequest - { - public class IsDatabaseOpenQueryHandler: IRequestHandler - { - private readonly IDatabaseProxy _databaseProxy; - - public IsDatabaseOpenQueryHandler(IDatabaseProxy databaseProxy) - { - _databaseProxy = databaseProxy; - } - public Task Handle(IsDatabaseOpenQuery request, CancellationToken cancellationToken) - { - return Task.FromResult(_databaseProxy.IsOpen); - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Database/Queries/OpenDatabase/OpenDatabaseQuery.cs b/ModernKeePass.Application.12/Database/Queries/OpenDatabase/OpenDatabaseQuery.cs deleted file mode 100644 index 0fd8917..0000000 --- a/ModernKeePass.Application.12/Database/Queries/OpenDatabase/OpenDatabaseQuery.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using AutoMapper; -using MediatR; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Application.Database.Models; -using ModernKeePass.Application.Database.Queries.IsDatabaseOpen; -using ModernKeePass.Application.Group.Models; -using ModernKeePass.Domain.Dtos; -using ModernKeePass.Domain.Exceptions; - -namespace ModernKeePass.Application.Database.Queries.OpenDatabase -{ - public class OpenDatabaseQuery: IRequest - { - public FileInfo FileInfo { get; set; } - public Credentials Credentials { get; set; } - - public class OpenDatabaseQueryHandler : IRequestHandler - { - private readonly IMapper _mapper; - private readonly IMediator _mediator; - private readonly IDatabaseProxy _databaseProxy; - - public OpenDatabaseQueryHandler(IMapper mapper, IMediator mediator, IDatabaseProxy databaseProxy) - { - _mapper = mapper; - _mediator = mediator; - _databaseProxy = databaseProxy; - } - - public async Task Handle(OpenDatabaseQuery request, CancellationToken cancellationToken) - { - var isDatabaseOpen = await _mediator.Send(new IsDatabaseOpenQuery(), cancellationToken); - if (isDatabaseOpen) throw new DatabaseOpenException(); - - var database = await _databaseProxy.Open(request.FileInfo, request.Credentials); - var databaseVm = new DatabaseVm - { - IsOpen = true, - Name = database.Name, - RootGroup = _mapper.Map(database.RootGroupEntity) - }; - return databaseVm; - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Database/Queries/OpenDatabase/OpenDatabaseQueryValidator.cs b/ModernKeePass.Application.12/Database/Queries/OpenDatabase/OpenDatabaseQueryValidator.cs deleted file mode 100644 index d773f08..0000000 --- a/ModernKeePass.Application.12/Database/Queries/OpenDatabase/OpenDatabaseQueryValidator.cs +++ /dev/null @@ -1,12 +0,0 @@ -using FluentValidation; - -namespace ModernKeePass.Application.Database.Queries.OpenDatabase -{ - public class OpenDatabaseQueryValidator : AbstractValidator - { - public OpenDatabaseQueryValidator() - { - RuleFor(v => v.Credentials != null && v.FileInfo != null); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/DependencyInjection.cs b/ModernKeePass.Application.12/DependencyInjection.cs deleted file mode 100644 index 0328d9a..0000000 --- a/ModernKeePass.Application.12/DependencyInjection.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; - -namespace ModernKeePass.Application -{ - public static class DependencyInjection - { - public static IServiceCollection AddApplication(this IServiceCollection services) - { - - return services; - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Entry/Models/EntryVm.cs b/ModernKeePass.Application.12/Entry/Models/EntryVm.cs deleted file mode 100644 index 44f6bcd..0000000 --- a/ModernKeePass.Application.12/Entry/Models/EntryVm.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Drawing; -using AutoMapper; -using ModernKeePass.Application.Common.Mappings; -using ModernKeePass.Domain.Entities; -using ModernKeePass.Domain.Enums; - -namespace ModernKeePass.Application.Entry.Models -{ - public class EntryVm: IMapFrom - { - public string Id { get; set; } - public string Title { get; set; } - public Icon Icon { get; set; } - public Color ForegroundColor { get; set; } - public Color BackgroundColor { get; set; } - - public void Mapping(Profile profile) - { - profile.CreateMap() - .ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id)) - .ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name)) - .ForMember(d => d.Icon, opts => opts.MapFrom(s => s.Icon)) - .ForMember(d => d.ForegroundColor, opts => opts.MapFrom(s => s.ForegroundColor)) - .ForMember(d => d.BackgroundColor, opts => opts.MapFrom(s => s.BackgroundColor)); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Group/Models/GroupVm.cs b/ModernKeePass.Application.12/Group/Models/GroupVm.cs deleted file mode 100644 index 3ba48f7..0000000 --- a/ModernKeePass.Application.12/Group/Models/GroupVm.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; -using System.Drawing; -using AutoMapper; -using ModernKeePass.Application.Common.Mappings; -using ModernKeePass.Application.Entry.Models; -using ModernKeePass.Domain.Entities; -using ModernKeePass.Domain.Enums; - -namespace ModernKeePass.Application.Group.Models -{ - public class GroupVm: IMapFrom - { - public string Id { get; set; } - public string Title { get; set; } - public Icon Icon { get; set; } - public Color ForegroundColor { get; set; } - public Color BackgroundColor { get; set; } - public List SubGroups { get; set; } = new List(); - public List Entries { get; set; } = new List(); - - public void Mapping(Profile profile) - { - profile.CreateMap() - .ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id)) - .ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name)) - .ForMember(d => d.Icon, opts => opts.MapFrom(s => s.Icon)) - .ForMember(d => d.ForegroundColor, opts => opts.MapFrom(s => s.ForegroundColor)) - .ForMember(d => d.BackgroundColor, opts => opts.MapFrom(s => s.BackgroundColor)) - .ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries)) - .ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.SubGroups)); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/ModernKeePass.Application.csproj b/ModernKeePass.Application.12/ModernKeePass.Application.csproj deleted file mode 100644 index 8c133a3..0000000 --- a/ModernKeePass.Application.12/ModernKeePass.Application.csproj +++ /dev/null @@ -1,59 +0,0 @@ - - - - netstandard1.2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ModernKeePass.Application.12/Services/CryptographyService.cs b/ModernKeePass.Application.12/Services/CryptographyService.cs deleted file mode 100644 index caa6a57..0000000 --- a/ModernKeePass.Application.12/Services/CryptographyService.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Entities; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Application.Services -{ - public class CryptographyService : ICryptographyService - { - private readonly ICryptographyClient _cryptographyClient; - public IEnumerable Ciphers => _cryptographyClient.Ciphers; - - public IEnumerable KeyDerivations => _cryptographyClient.KeyDerivations; - - public IEnumerable CompressionAlgorithms => _cryptographyClient.CompressionAlgorithms; - - public CryptographyService(ICryptographyClient cryptographyClient) - { - _cryptographyClient = cryptographyClient; - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Services/DatabaseService.cs b/ModernKeePass.Application.12/Services/DatabaseService.cs deleted file mode 100644 index cbfe4ce..0000000 --- a/ModernKeePass.Application.12/Services/DatabaseService.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Threading.Tasks; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Dtos; -using ModernKeePass.Domain.Entities; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Application.Services -{ - public class DatabaseService: IDatabaseService - { - private readonly IDatabaseProxy _databaseProxy; - - public string Name { get; private set; } - public bool IsOpen { get; private set; } - public Domain.Entities.GroupEntity RootGroupEntity { get; private set; } - public Domain.Entities.GroupEntity RecycleBin - { - get => _databaseProxy.RecycleBin; - set => _databaseProxy.RecycleBin = value; - } - public Entity Cipher - { - get => _databaseProxy.Cipher; - set => _databaseProxy.Cipher = value; - } - public Entity KeyDerivation - { - get => _databaseProxy.KeyDerivation; - set => _databaseProxy.KeyDerivation = value; - } - public string Compression - { - get => _databaseProxy.Compression; - set => _databaseProxy.Compression = value; - } - public bool IsRecycleBinEnabled => RecycleBin != null; - - public DatabaseService(IDatabaseProxy databaseProxy) - { - _databaseProxy = databaseProxy; - } - - public async Task Open(FileInfo fileInfo, Credentials credentials) - { - RootGroupEntity = await _databaseProxy.Open(fileInfo, credentials); - Name = RootGroupEntity?.Name; - IsOpen = true; - } - - public async Task Create(FileInfo fileInfo, Credentials credentials) - { - RootGroupEntity = await _databaseProxy.Create(fileInfo, credentials); - Name = RootGroupEntity?.Name; - IsOpen = true; - } - - public async Task Save() - { - await _databaseProxy.SaveDatabase(); - } - - public async Task SaveAs(FileInfo fileInfo) - { - await _databaseProxy.SaveDatabase(fileInfo); - } - - public Task CreateRecycleBin(Domain.Entities.GroupEntity recycleBinGroupEntity) - { - throw new NotImplementedException(); - } - - public async Task UpdateCredentials(Credentials credentials) - { - await _databaseProxy.UpdateCredentials(credentials); - await Save(); - } - - public void Close() - { - _databaseProxy.CloseDatabase(); - IsOpen = false; - } - - public async Task AddEntity(GroupEntity parentEntity, Entity entity) - { - await _databaseProxy.AddEntity(parentEntity, entity); - //await Save(); - } - - public async Task UpdateEntity(Entity entity) - { - await _databaseProxy.UpdateEntity(entity); - } - - public async Task DeleteEntity(Entity entity) - { - if (IsRecycleBinEnabled) await AddEntity(RecycleBin, entity); - await _databaseProxy.DeleteEntity(entity); - //await Save(); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Services/FileService.cs b/ModernKeePass.Application.12/Services/FileService.cs deleted file mode 100644 index 6d85c01..0000000 --- a/ModernKeePass.Application.12/Services/FileService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Application.Services -{ - public class FileService: IFileService - { - private readonly IFileProxy _fileProxy; - - public FileService(IFileProxy fileProxy) - { - _fileProxy = fileProxy; - } - - public Task OpenBinaryFile(string path) - { - return _fileProxy.OpenBinaryFile(path); - } - - public Task WriteBinaryContentsToFile(string path, byte[] contents) - { - return _fileProxy.WriteBinaryContentsToFile(path, contents); - } - - public Task> OpenTextFile(string path) - { - return _fileProxy.OpenTextFile(path); - } - - public void ReleaseFile(string path) - { - _fileProxy.ReleaseFile(path); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Services/ImportService.cs b/ModernKeePass.Application.12/Services/ImportService.cs deleted file mode 100644 index ca1b40e..0000000 --- a/ModernKeePass.Application.12/Services/ImportService.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Threading.Tasks; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Entities; -using ModernKeePass.Domain.Enums; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Application.Services -{ - public class ImportService: IImportService - { - private readonly Func _importFormatProviders; - - public ImportService(Func importFormatProviders) - { - _importFormatProviders = importFormatProviders; - } - - public async Task Import(ImportFormat format, string filePath, Group group) - { - var importProvider = _importFormatProviders(format); - var data = await importProvider.Import(filePath); - - /*foreach (var entity in data) - { - var entry = group.AddNewEntry(); - entry.Name = entity["0"]; - entry.UserName = entity["1"]; - entry.Password = entity["2"]; - if (entity.Count > 3) entry.Url = entity["3"]; - if (entity.Count > 4) entry.Notes = entity["4"]; - }*/ - } - } -} diff --git a/ModernKeePass.Application.12/Services/RecentService.cs b/ModernKeePass.Application.12/Services/RecentService.cs deleted file mode 100644 index 13f2625..0000000 --- a/ModernKeePass.Application.12/Services/RecentService.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Dtos; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Application.Services -{ - public class RecentService: IRecentService - { - private readonly IRecentProxy _recentProxy; - - public RecentService(IRecentProxy recentProxy) - { - _recentProxy = recentProxy; - } - - public bool HasEntries => _recentProxy.EntryCount > 0; - - public async Task Get(string token) - { - return await _recentProxy.Get(token); - } - - public async Task> GetAll() - { - return await _recentProxy.GetAll(); - } - - public async Task Add(FileInfo recentItem) - { - await _recentProxy.Add(recentItem); - } - - public void ClearAll() - { - _recentProxy.ClearAll(); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Services/ResourceService.cs b/ModernKeePass.Application.12/Services/ResourceService.cs deleted file mode 100644 index 8f3e920..0000000 --- a/ModernKeePass.Application.12/Services/ResourceService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Application.Services -{ - public class ResourceService: IResourceService - { - private readonly IResourceProxy _resourceProxy; - - public ResourceService(IResourceProxy resourceProxy) - { - _resourceProxy = resourceProxy; - } - - public string GetResourceValue(string key) - { - return _resourceProxy.GetResourceValue(key); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Services/SecurityService.cs b/ModernKeePass.Application.12/Services/SecurityService.cs deleted file mode 100644 index 14918fe..0000000 --- a/ModernKeePass.Application.12/Services/SecurityService.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Threading.Tasks; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Dtos; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Application.Services -{ - public class SecurityService: ISecurityService - { - private readonly IPasswordProxy _passwordProxy; - private readonly IFileService _fileService; - - public SecurityService(IPasswordProxy passwordProxy, IFileService fileService) - { - _passwordProxy = passwordProxy; - _fileService = fileService; - } - - public string GeneratePassword(PasswordGenerationOptions options) - { - return _passwordProxy.GeneratePassword(options); - } - - public uint EstimatePasswordComplexity(string password) - { - return _passwordProxy.EstimatePasswordComplexity(password); - } - - public async Task GenerateKeyFile(string filePath) - { - var fileContents = _passwordProxy.GenerateKeyFile(null); - await _fileService.WriteBinaryContentsToFile(filePath, fileContents); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Application.12/Services/SettingsService.cs b/ModernKeePass.Application.12/Services/SettingsService.cs deleted file mode 100644 index 2c16006..0000000 --- a/ModernKeePass.Application.12/Services/SettingsService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Application.Services -{ - public class SettingsService: ISettingsService - { - private readonly ISettingsProxy _settingsProxy; - - public SettingsService(ISettingsProxy settingsProxy) - { - _settingsProxy = settingsProxy; - } - - public T GetSetting(string property, T defaultValue = default) - { - return _settingsProxy.GetSetting(property, defaultValue); - } - - public void PutSetting(string property, T value) - { - _settingsProxy.PutSetting(property, value); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/AOP/NotifyPropertyChangedBase.cs b/ModernKeePass.Domain.12/AOP/NotifyPropertyChangedBase.cs deleted file mode 100644 index c9ab235..0000000 --- a/ModernKeePass.Domain.12/AOP/NotifyPropertyChangedBase.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel; -using System.Runtime.CompilerServices; - -namespace ModernKeePass.Domain.AOP -{ - public class NotifyPropertyChangedBase : INotifyPropertyChanged - { - public event PropertyChangedEventHandler PropertyChanged; - - protected void OnPropertyChanged(string propertyName = "") - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - - protected bool SetProperty(ref T property, T value, [CallerMemberName] string propertyName = "") - { - if (EqualityComparer.Default.Equals(property, value)) - { - return false; - } - - property = value; - OnPropertyChanged(propertyName); - return true; - } - } -} diff --git a/ModernKeePass.Domain.12/Dtos/Credentials.cs b/ModernKeePass.Domain.12/Dtos/Credentials.cs deleted file mode 100644 index bdb3091..0000000 --- a/ModernKeePass.Domain.12/Dtos/Credentials.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ModernKeePass.Domain.Dtos -{ - public class Credentials - { - public string Password { get; set; } - public string KeyFilePath { get; set; } - // TODO: add Windows Hello - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Dtos/FileInfo.cs b/ModernKeePass.Domain.12/Dtos/FileInfo.cs deleted file mode 100644 index ad122b6..0000000 --- a/ModernKeePass.Domain.12/Dtos/FileInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ModernKeePass.Domain.Dtos -{ - public class FileInfo - { - public string Name { get; set; } - public string Path { get; set; } - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Dtos/PasswordGenerationOptions.cs b/ModernKeePass.Domain.12/Dtos/PasswordGenerationOptions.cs deleted file mode 100644 index bc40931..0000000 --- a/ModernKeePass.Domain.12/Dtos/PasswordGenerationOptions.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace ModernKeePass.Domain.Dtos -{ - public class PasswordGenerationOptions - { - public int PasswordLength { get; set; } - public bool UpperCasePatternSelected { get; set; } - public bool LowerCasePatternSelected { get; set; } - public bool DigitsPatternSelected { get; set; } - public bool SpecialPatternSelected { get; set; } - public bool MinusPatternSelected { get; set; } - public bool UnderscorePatternSelected { get; set; } - public bool SpacePatternSelected { get; set; } - public bool BracketsPatternSelected { get; set; } - public string CustomChars { get; set; } - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Entities/BaseEntity.cs b/ModernKeePass.Domain.12/Entities/BaseEntity.cs deleted file mode 100644 index 0ba8e03..0000000 --- a/ModernKeePass.Domain.12/Entities/BaseEntity.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Drawing; - -namespace ModernKeePass.Domain.Entities -{ - public class BaseEntity - { - public string Id { get; set; } - public string Name { get; set; } - public Color ForegroundColor { get; set; } - public Color BackgroundColor { get; set; } - public DateTimeOffset LastModificationDate { get; set; } - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Entities/DatabaseEntity.cs b/ModernKeePass.Domain.12/Entities/DatabaseEntity.cs deleted file mode 100644 index 3c58b65..0000000 --- a/ModernKeePass.Domain.12/Entities/DatabaseEntity.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ModernKeePass.Domain.Entities -{ - public class DatabaseEntity - { - public string Name { get; set; } - - public GroupEntity RootGroupEntity { get; set; } - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Entities/EntryEntity.cs b/ModernKeePass.Domain.12/Entities/EntryEntity.cs deleted file mode 100644 index 47139bb..0000000 --- a/ModernKeePass.Domain.12/Entities/EntryEntity.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using ModernKeePass.Domain.Enums; - -namespace ModernKeePass.Domain.Entities -{ - public class EntryEntity: BaseEntity - { - public string UserName { get; set; } - public string Password { get; set; } - public Uri Url { get; set; } - public string Notes { get; set; } - public DateTimeOffset ExpirationDate { get; set; } - public Color ForegroundColor { get; set; } - public Color BackgroundColor { get; set; } - public Dictionary AdditionalFields { get; set; } = new Dictionary(); - public IEnumerable History { get; set; } - public Icon Icon { get; set; } - public bool HasExpirationDate { get; set; } - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Entities/GroupEntity.cs b/ModernKeePass.Domain.12/Entities/GroupEntity.cs deleted file mode 100644 index f538150..0000000 --- a/ModernKeePass.Domain.12/Entities/GroupEntity.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; -using ModernKeePass.Domain.Enums; - -namespace ModernKeePass.Domain.Entities -{ - public class GroupEntity : BaseEntity - { - public List SubGroups { get; set; } = new List(); - public List Entries { get; set; } = new List(); - public Icon Icon { get; set; } - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Enums/CredentialStatusTypes.cs b/ModernKeePass.Domain.12/Enums/CredentialStatusTypes.cs deleted file mode 100644 index 7e63087..0000000 --- a/ModernKeePass.Domain.12/Enums/CredentialStatusTypes.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ModernKeePass.Domain.Enums -{ - public enum CredentialStatusTypes - { - Normal = 0, - Error = 1, - Warning = 3, - Success = 5 - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Enums/Icon.cs b/ModernKeePass.Domain.12/Enums/Icon.cs deleted file mode 100644 index 3584568..0000000 --- a/ModernKeePass.Domain.12/Enums/Icon.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace ModernKeePass.Domain.Enums -{ - public enum Icon - { - Delete, - Edit, - Save, - Cancel, - Accept, - Home, - Camera, - Setting, - Mail, - Find, - Help, - Clock, - Crop, - World, - Flag, - PreviewLink, - Document, - ProtectedDocument, - ContactInfo, - ViewAll, - Rotate, - List, - Shop, - BrowsePhotos, - Caption, - Repair, - Page, - Paste, - Important, - SlideShow, - MapDrive, - ContactPresence, - Contact, - Folder, - View, - Permissions, - Map, - CellPhone, - OutlineStar, - Calculator, - Library, - SyncFolder, - GoToStart, - ZeroBars, - FourBars, - Scan, - ReportHacked, - Stop - } -} diff --git a/ModernKeePass.Domain.12/Enums/ImportFormat.cs b/ModernKeePass.Domain.12/Enums/ImportFormat.cs deleted file mode 100644 index 9044d9c..0000000 --- a/ModernKeePass.Domain.12/Enums/ImportFormat.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace ModernKeePass.Domain.Enums -{ - public enum ImportFormat - { - CSV - } -} diff --git a/ModernKeePass.Domain.12/Exceptions/DatabaseClosedException.cs b/ModernKeePass.Domain.12/Exceptions/DatabaseClosedException.cs deleted file mode 100644 index 3961243..0000000 --- a/ModernKeePass.Domain.12/Exceptions/DatabaseClosedException.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace ModernKeePass.Domain.Exceptions -{ - public class DatabaseClosedException: Exception - { } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Exceptions/DatabaseOpenException.cs b/ModernKeePass.Domain.12/Exceptions/DatabaseOpenException.cs deleted file mode 100644 index 5633409..0000000 --- a/ModernKeePass.Domain.12/Exceptions/DatabaseOpenException.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace ModernKeePass.Domain.Exceptions -{ - public class DatabaseOpenException: Exception - { } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Exceptions/NavigationException.cs b/ModernKeePass.Domain.12/Exceptions/NavigationException.cs deleted file mode 100644 index ea93e00..0000000 --- a/ModernKeePass.Domain.12/Exceptions/NavigationException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace ModernKeePass.Domain.Exceptions -{ - public class NavigationException: Exception - { - public NavigationException(Type pageType) : base($"Failed to load Page {pageType.FullName}") - { - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Domain.12/Exceptions/SaveException.cs b/ModernKeePass.Domain.12/Exceptions/SaveException.cs deleted file mode 100644 index 4ad0818..0000000 --- a/ModernKeePass.Domain.12/Exceptions/SaveException.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace ModernKeePass.Domain.Exceptions -{ - public class SaveException : Exception - { - public new Exception InnerException { get; } - - public SaveException(Exception exception) - { - InnerException = exception; - } - } -} diff --git a/ModernKeePass.Domain.12/ModernKeePass.Domain.csproj b/ModernKeePass.Domain.12/ModernKeePass.Domain.csproj deleted file mode 100644 index c2744a9..0000000 --- a/ModernKeePass.Domain.12/ModernKeePass.Domain.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - netstandard1.2 - - - - - - - diff --git a/ModernKeePass.Infrastucture.12/DependencyInjection.cs b/ModernKeePass.Infrastucture.12/DependencyInjection.cs deleted file mode 100644 index bbebb55..0000000 --- a/ModernKeePass.Infrastucture.12/DependencyInjection.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Autofac; -using AutoMapper; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Infrastructure.KeePass; -using ModernKeePass.Infrastructure.UWP; - -namespace ModernKeePass.Infrastructure -{ - public class DependencyInjection: Module - { - protected override void Load(ContainerBuilder builder) - { - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As(); - builder.RegisterType().As(); - builder.RegisterType().As(); - builder.RegisterType().As(); - builder.RegisterType().As(); - - // Register Automapper profiles - builder.RegisterType().As(); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/File/CsvImportFormat.cs b/ModernKeePass.Infrastucture.12/File/CsvImportFormat.cs deleted file mode 100644 index a240a50..0000000 --- a/ModernKeePass.Infrastucture.12/File/CsvImportFormat.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using ModernKeePass.Application.Common.Interfaces; - -namespace ModernKeePass.Infrastructure.File -{ - public class CsvImportFormat: IImportFormat - { - private readonly IFileProxy _fileService; - private const bool HasHeaderRow = true; - private const char Delimiter = ';'; - private const char LineDelimiter = '\n'; - - public CsvImportFormat(IFileProxy fileService) - { - _fileService = fileService; - } - - public async Task>> Import(string path) - { - var parsedResult = new List>(); - var content = await _fileService.OpenTextFile(path); - foreach (var line in content) - { - var fields = line.Split(Delimiter); - var recordItem = new Dictionary(); - var i = 0; - foreach (var field in fields) - { - recordItem.Add(i.ToString(), field); - i++; - } - parsedResult.Add(recordItem); - } - - return parsedResult; - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/KeePass/EntryMappingProfile.cs b/ModernKeePass.Infrastucture.12/KeePass/EntryMappingProfile.cs deleted file mode 100644 index a767cf9..0000000 --- a/ModernKeePass.Infrastucture.12/KeePass/EntryMappingProfile.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Linq; -using AutoMapper; -using ModernKeePass.Domain.Entities; -using ModernKeePassLib; -using ModernKeePassLib.Security; - -namespace ModernKeePass.Infrastructure.KeePass -{ - public class EntryMappingProfile: Profile - { - public EntryMappingProfile() - { - FromModelToDto(); - FromDtoToModel(); - } - - private void FromDtoToModel() - { - CreateMap() - .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Uuid.ToHexString())) - .ForMember(dest => dest.Name, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.TitleField))) - .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.UserNameField))) - .ForMember(dest => dest.Password, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.PasswordField))) - .ForMember(dest => dest.Url, opt => - { - opt.PreCondition(src => Uri.TryCreate(GetEntryValue(src, PwDefs.UrlField), UriKind.Absolute, out _)); - opt.MapFrom(src => new Uri(GetEntryValue(src, PwDefs.UrlField))); - }) - .ForMember(dest => dest.Notes, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.NotesField))) - .ForMember(dest => dest.ForegroundColor, opt => opt.MapFrom(src => src.ForegroundColor)) - .ForMember(dest => dest.BackgroundColor, opt => opt.MapFrom(src => src.BackgroundColor)) - .ForMember(dest => dest.ExpirationDate, opt => opt.MapFrom(src => new DateTimeOffset(src.ExpiryTime))) - .ForMember(dest => dest.HasExpirationDate, opt => opt.MapFrom(src => src.Expires)) - .ForMember(dest => dest.Icon, opt => opt.MapFrom(src => IconMapper.MapPwIconToIcon(src.IconId))) - .ForMember(dest => dest.AdditionalFields, opt => opt.MapFrom(src => - src.Strings.Where(s => !PwDefs.GetStandardFields().Contains(s.Key)).ToDictionary(s => s.Key, s => GetEntryValue(src, s.Key)))) - .ForMember(dest => dest.LastModificationDate, opt => opt.MapFrom(src => new DateTimeOffset(src.LastModificationTime))); - } - - private void FromModelToDto() - { - CreateMap().ConvertUsing(); - } - - private string GetEntryValue(PwEntry entry, string key) => entry.Strings.GetSafe(key).ReadString(); - } - - public class EntryToPwEntryDictionaryConverter : ITypeConverter - { - public PwEntry Convert(EntryEntity source, PwEntry destination, ResolutionContext context) - { - //destination.Uuid = new PwUuid(System.Convert.FromBase64String(source.Id)); - destination.ExpiryTime = source.ExpirationDate.DateTime; - destination.Expires = source.HasExpirationDate; - destination.LastModificationTime = source.LastModificationDate.DateTime; - destination.BackgroundColor = source.BackgroundColor; - destination.ForegroundColor = source.ForegroundColor; - destination.IconId = IconMapper.MapIconToPwIcon(source.Icon); - SetEntryValue(destination, PwDefs.TitleField, source.Name); - SetEntryValue(destination, PwDefs.UserNameField, source.UserName); - SetEntryValue(destination, PwDefs.PasswordField, source.Password); - SetEntryValue(destination, PwDefs.UrlField, source.Url?.ToString()); - SetEntryValue(destination, PwDefs.NotesField, source.Notes); - foreach (var additionalField in source.AdditionalFields) - { - SetEntryValue(destination, additionalField.Key, additionalField.Value); - } - return destination; - } - private void SetEntryValue(PwEntry entry, string key, string newValue) - { - if (newValue != null) entry.Strings.Set(key, new ProtectedString(true, newValue)); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/KeePass/IconMapper.cs b/ModernKeePass.Infrastucture.12/KeePass/IconMapper.cs deleted file mode 100644 index 47c254a..0000000 --- a/ModernKeePass.Infrastucture.12/KeePass/IconMapper.cs +++ /dev/null @@ -1,126 +0,0 @@ -using ModernKeePass.Domain.Enums; -using ModernKeePassLib; - -namespace ModernKeePass.Infrastructure.KeePass -{ - public static class IconMapper - { - public static Icon MapPwIconToIcon(PwIcon value) - { - switch (value) - { - case PwIcon.Key: return Icon.Permissions; - case PwIcon.WorldSocket: - case PwIcon.World: return Icon.World; - case PwIcon.Warning: return Icon.Important; - case PwIcon.WorldComputer: - case PwIcon.Drive: - case PwIcon.DriveWindows: - case PwIcon.NetworkServer: return Icon.MapDrive; - case PwIcon.MarkedDirectory: return Icon.Map; - case PwIcon.UserCommunication: return Icon.ContactInfo; - case PwIcon.Parts: return Icon.ViewAll; - case PwIcon.Notepad: return Icon.Document; - case PwIcon.Identity: return Icon.Contact; - case PwIcon.PaperReady: return Icon.SyncFolder; - case PwIcon.Digicam: return Icon.Camera; - case PwIcon.IRCommunication: return Icon.View; - case PwIcon.Energy: return Icon.ZeroBars; - case PwIcon.Scanner: return Icon.Scan; - case PwIcon.CDRom: return Icon.Rotate; - case PwIcon.Monitor: return Icon.Caption; - case PwIcon.EMailBox: - case PwIcon.EMail: return Icon.Mail; - case PwIcon.Configuration: return Icon.Setting; - case PwIcon.ClipboardReady: return Icon.Paste; - case PwIcon.PaperNew: return Icon.Page; - case PwIcon.Screen: return Icon.GoToStart; - case PwIcon.EnergyCareful: return Icon.FourBars; - case PwIcon.Disk: return Icon.Save; - case PwIcon.Console: return Icon.SlideShow; - case PwIcon.Printer: return Icon.Scan; - case PwIcon.ProgramIcons: return Icon.GoToStart; - case PwIcon.Settings: - case PwIcon.Tool: return Icon.Repair; - case PwIcon.Archive: return Icon.Crop; - case PwIcon.Count: return Icon.Calculator; - case PwIcon.Clock: return Icon.Clock; - case PwIcon.EMailSearch: return Icon.Find; - case PwIcon.PaperFlag: return Icon.Flag; - case PwIcon.TrashBin: return Icon.Delete; - case PwIcon.Expired: return Icon.ReportHacked; - case PwIcon.Info: return Icon.Help; - case PwIcon.Folder: - case PwIcon.FolderOpen: - case PwIcon.FolderPackage: return Icon.Folder; - case PwIcon.PaperLocked: return Icon.ProtectedDocument; - case PwIcon.Checked: return Icon.Accept; - case PwIcon.Pen: return Icon.Edit; - case PwIcon.Thumbnail: return Icon.BrowsePhotos; - case PwIcon.Book: return Icon.Library; - case PwIcon.List: return Icon.List; - case PwIcon.UserKey: return Icon.ContactPresence; - case PwIcon.Home: return Icon.Home; - case PwIcon.Star: return Icon.OutlineStar; - case PwIcon.Money: return Icon.Shop; - case PwIcon.Certificate: return Icon.PreviewLink; - case PwIcon.BlackBerry: return Icon.CellPhone; - default: return Icon.Stop; - } - } - - public static PwIcon MapIconToPwIcon(Icon value) - { - switch (value) - { - case Icon.Delete: return PwIcon.TrashBin; - case Icon.Edit: return PwIcon.Pen; - case Icon.Save: return PwIcon.Disk; - case Icon.Cancel: return PwIcon.Expired; - case Icon.Accept: return PwIcon.Checked; - case Icon.Home: return PwIcon.Home; - case Icon.Camera: return PwIcon.Digicam; - case Icon.Setting: return PwIcon.Configuration; - case Icon.Mail: return PwIcon.EMail; - case Icon.Find: return PwIcon.EMailSearch; - case Icon.Help: return PwIcon.Info; - case Icon.Clock: return PwIcon.Clock; - case Icon.Crop: return PwIcon.Archive; - case Icon.World: return PwIcon.World; - case Icon.Flag: return PwIcon.PaperFlag; - case Icon.PreviewLink: return PwIcon.Certificate; - case Icon.Document: return PwIcon.Notepad; - case Icon.ProtectedDocument: return PwIcon.PaperLocked; - case Icon.ContactInfo: return PwIcon.UserCommunication; - case Icon.ViewAll: return PwIcon.Parts; - case Icon.Rotate: return PwIcon.CDRom; - case Icon.List: return PwIcon.List; - case Icon.Shop: return PwIcon.Money; - case Icon.BrowsePhotos: return PwIcon.Thumbnail; - case Icon.Caption: return PwIcon.Monitor; - case Icon.Repair: return PwIcon.Tool; - case Icon.Page: return PwIcon.PaperNew; - case Icon.Paste: return PwIcon.ClipboardReady; - case Icon.Important: return PwIcon.Warning; - case Icon.SlideShow: return PwIcon.Console; - case Icon.MapDrive: return PwIcon.NetworkServer; - case Icon.ContactPresence: return PwIcon.UserKey; - case Icon.Contact: return PwIcon.Identity; - case Icon.Folder: return PwIcon.Folder; - case Icon.View: return PwIcon.IRCommunication; - case Icon.Permissions: return PwIcon.Key; - case Icon.Map: return PwIcon.MarkedDirectory; - case Icon.CellPhone: return PwIcon.BlackBerry; - case Icon.OutlineStar: return PwIcon.Star; - case Icon.Calculator: return PwIcon.Count; - case Icon.Library: return PwIcon.Book; - case Icon.SyncFolder: return PwIcon.PaperReady; - case Icon.GoToStart: return PwIcon.Screen; - case Icon.ZeroBars: return PwIcon.Energy; - case Icon.FourBars: return PwIcon.EnergyCareful; - case Icon.Scan: return PwIcon.Scanner; - default: return PwIcon.Key; - } - } - } -} diff --git a/ModernKeePass.Infrastucture.12/KeePass/KeePassCryptographyClient.cs b/ModernKeePass.Infrastucture.12/KeePass/KeePassCryptographyClient.cs deleted file mode 100644 index 9dfb3b0..0000000 --- a/ModernKeePass.Infrastucture.12/KeePass/KeePassCryptographyClient.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Entities; -using ModernKeePassLib; -using ModernKeePassLib.Cryptography.Cipher; -using ModernKeePassLib.Cryptography.KeyDerivation; - -namespace ModernKeePass.Infrastructure.KeePass -{ - public class KeePassCryptographyClient: ICryptographyClient - { - public IEnumerable Ciphers - { - get - { - for (var inx = 0; inx < CipherPool.GlobalPool.EngineCount; inx++) - { - var cipher = CipherPool.GlobalPool[inx]; - yield return new BaseEntity - { - Id = cipher.CipherUuid.ToHexString(), - Name = cipher.DisplayName - }; - } - } - } - - public IEnumerable KeyDerivations => KdfPool.Engines.Select(e => new BaseEntity - { - Id = e.Uuid.ToHexString(), - Name = e.Name - }); - - public IEnumerable CompressionAlgorithms => Enum.GetNames(typeof(PwCompressionAlgorithm)).Take((int) PwCompressionAlgorithm.Count); - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/KeePass/KeePassDatabaseClient.cs b/ModernKeePass.Infrastucture.12/KeePass/KeePassDatabaseClient.cs deleted file mode 100644 index 47aff20..0000000 --- a/ModernKeePass.Infrastucture.12/KeePass/KeePassDatabaseClient.cs +++ /dev/null @@ -1,266 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using AutoMapper; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Dtos; -using ModernKeePass.Domain.Entities; -using ModernKeePass.Domain.Exceptions; -using ModernKeePassLib; -using ModernKeePassLib.Cryptography.Cipher; -using ModernKeePassLib.Cryptography.KeyDerivation; -using ModernKeePassLib.Interfaces; -using ModernKeePassLib.Keys; -using ModernKeePassLib.Serialization; -using ModernKeePassLib.Utility; - -namespace ModernKeePass.Infrastructure.KeePass -{ - public class KeePassDatabaseClient: IDatabaseProxy - { - private readonly ISettingsProxy _settings; - private readonly IFileProxy _fileService; - private readonly IMapper _mapper; - private readonly PwDatabase _pwDatabase = new PwDatabase(); - private string _fileAccessToken; - private CompositeKey _compositeKey; - - public bool IsOpen => (_pwDatabase?.IsOpen).GetValueOrDefault(); - - public GroupEntity RecycleBin { get; set; } - - public BaseEntity Cipher - { - get - { - var cipher = CipherPool.GlobalPool.GetCipher(_pwDatabase.DataCipherUuid); - return new BaseEntity - { - Id = cipher.CipherUuid.ToHexString(), - Name = cipher.DisplayName - }; - } - set => _pwDatabase.DataCipherUuid = BuildIdFromString(value.Id); - } - - public BaseEntity KeyDerivation - { - get - { - var keyDerivation = KdfPool.Engines.First(e => e.Uuid.Equals(_pwDatabase.KdfParameters.KdfUuid)); - return new BaseEntity - { - Id = keyDerivation.Uuid.ToHexString(), - Name = keyDerivation.Name - }; - } - set => _pwDatabase.KdfParameters = KdfPool.Engines - .FirstOrDefault(e => e.Uuid.Equals(BuildIdFromString(value.Name)))?.GetDefaultParameters(); - } - - public string Compression - { - get => _pwDatabase.Compression.ToString("G"); - set => _pwDatabase.Compression = (PwCompressionAlgorithm)Enum.Parse(typeof(PwCompressionAlgorithm), value); - } - - public KeePassDatabaseClient(ISettingsProxy settings, IFileProxy fileService, IMapper mapper) - { - _settings = settings; - _fileService = fileService; - _mapper = mapper; - } - - public async Task Open(FileInfo fileInfo, Credentials credentials) - { - try - { - _compositeKey = await CreateCompositeKey(credentials); - var ioConnection = await BuildConnectionInfo(fileInfo); - - _pwDatabase.Open(ioConnection, _compositeKey, new NullStatusLogger()); - - _fileAccessToken = fileInfo.Path; - - return new DatabaseEntity - { - RootGroupEntity = BuildHierarchy(_pwDatabase.RootGroup) - }; - } - catch (InvalidCompositeKeyException ex) - { - throw new ArgumentException(ex.Message, ex); - } - } - - public async Task Create(FileInfo fileInfo, Credentials credentials) - { - _compositeKey = await CreateCompositeKey(credentials); - var ioConnection = await BuildConnectionInfo(fileInfo); - - _pwDatabase.New(ioConnection, _compositeKey); - - var fileFormat = _settings.GetSetting("DefaultFileFormat"); - switch (fileFormat) - { - case "4": - _pwDatabase.KdfParameters = KdfPool.Get("Argon2").GetDefaultParameters(); - break; - } - - _fileAccessToken = fileInfo.Path; - - // TODO: create sample data depending on settings - return new DatabaseEntity - { - RootGroupEntity = BuildHierarchy(_pwDatabase.RootGroup) - }; - } - - public async Task SaveDatabase() - { - if (!_pwDatabase.IsOpen) return; - try - { - _pwDatabase.Save(new NullStatusLogger()); - await _fileService.WriteBinaryContentsToFile(_fileAccessToken, _pwDatabase.IOConnectionInfo.Bytes); - } - catch (Exception e) - { - throw new SaveException(e); - } - } - - public async Task SaveDatabase(FileInfo fileInfo) - { - try - { - var newFileContents = await _fileService.OpenBinaryFile(fileInfo.Path); - _pwDatabase.SaveAs(IOConnectionInfo.FromByteArray(newFileContents), true, new NullStatusLogger()); - await _fileService.WriteBinaryContentsToFile(fileInfo.Path, _pwDatabase.IOConnectionInfo.Bytes); - - _fileService.ReleaseFile(_fileAccessToken); - _fileAccessToken = fileInfo.Path; - } - catch (Exception e) - { - throw new SaveException(e); - } - } - - public void CloseDatabase() - { - _pwDatabase?.Close(); - _fileService.ReleaseFile(_fileAccessToken); - } - - public async Task AddEntry(GroupEntity parentGroupEntity, EntryEntity entry) - { - await Task.Run(() => - { - var parentPwGroup = _pwDatabase.RootGroup.FindGroup(BuildIdFromString(parentGroupEntity.Id), true); - - var pwEntry = new PwEntry(true, true); - _mapper.Map(entry, pwEntry); - parentPwGroup.AddEntry(pwEntry, true); - entry.Id = pwEntry.Uuid.ToHexString(); - }); - } - public async Task AddGroup(GroupEntity parentGroupEntity, GroupEntity group) - { - await Task.Run(() => - { - var parentPwGroup = _pwDatabase.RootGroup.FindGroup(BuildIdFromString(parentGroupEntity.Id), true); - - var pwGroup = new PwGroup(true, true) - { - Name = group.Name - }; - parentPwGroup.AddGroup(pwGroup, true); - group.Id = pwGroup.Uuid.ToHexString(); - - }); - } - - public Task UpdateEntry(EntryEntity entry) - { - throw new NotImplementedException(); - } - - public Task UpdateGroup(GroupEntity group) - { - throw new NotImplementedException(); - } - - public async Task DeleteEntry(EntryEntity entry) - { - await Task.Run(() => - { - var pwEntry = _pwDatabase.RootGroup.FindEntry(BuildIdFromString(entry.Id), true); - var id = pwEntry.Uuid; - pwEntry.ParentGroup.Entries.Remove(pwEntry); - - if (_pwDatabase.RecycleBinEnabled) - { - _pwDatabase.DeletedObjects.Add(new PwDeletedObject(id, DateTime.UtcNow)); - } - }); - } - public async Task DeleteGroup(GroupEntity group) - { - await Task.Run(() => - { - var pwGroup = _pwDatabase.RootGroup.FindGroup(BuildIdFromString(group.Id), true); - var id = pwGroup.Uuid; - pwGroup.ParentGroup.Groups.Remove(pwGroup); - - if (_pwDatabase.RecycleBinEnabled) - { - _pwDatabase.DeletedObjects.Add(new PwDeletedObject(id, DateTime.UtcNow)); - } - }); - } - - public async Task UpdateCredentials(Credentials credentials) - { - _pwDatabase.MasterKey = await CreateCompositeKey(credentials); - } - - private async Task CreateCompositeKey(Credentials credentials) - { - var compositeKey = new CompositeKey(); - if (!string.IsNullOrEmpty(credentials.Password)) compositeKey.AddUserKey(new KcpPassword(credentials.Password)); - if (!string.IsNullOrEmpty(credentials.KeyFilePath)) - { - var kcpFileContents = await _fileService.OpenBinaryFile(credentials.KeyFilePath); - compositeKey.AddUserKey(new KcpKeyFile(IOConnectionInfo.FromByteArray(kcpFileContents))); - } - return compositeKey; - } - - private async Task BuildConnectionInfo(FileInfo fileInfo) - { - var fileContents = await _fileService.OpenBinaryFile(fileInfo.Path); - return IOConnectionInfo.FromByteArray(fileContents); - } - - private GroupEntity BuildHierarchy(PwGroup pwGroup) - { - // TODO: build entity hierarchy in an iterative way or implement lazy loading - var group = new GroupEntity - { - Id = pwGroup.Uuid.ToHexString(), - Name = pwGroup.Name, - Icon = IconMapper.MapPwIconToIcon(pwGroup.IconId), - Entries = pwGroup.Entries.Select(e => _mapper.Map(e)).ToList(), - SubGroups = pwGroup.Groups.Select(BuildHierarchy).ToList() - }; - return group; - } - - private PwUuid BuildIdFromString(string id) - { - return new PwUuid(MemUtil.HexStringToByteArray(id)); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/KeePass/KeePassPasswordClient.cs b/ModernKeePass.Infrastucture.12/KeePass/KeePassPasswordClient.cs deleted file mode 100644 index 199ae47..0000000 --- a/ModernKeePass.Infrastucture.12/KeePass/KeePassPasswordClient.cs +++ /dev/null @@ -1,46 +0,0 @@ -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Dtos; -using ModernKeePassLib.Cryptography; -using ModernKeePassLib.Cryptography.PasswordGenerator; -using ModernKeePassLib.Keys; - -namespace ModernKeePass.Infrastructure.KeePass -{ - public class KeePassPasswordClient: IPasswordProxy - { - public string GeneratePassword(PasswordGenerationOptions options) - { - var pwProfile = new PwProfile - { - GeneratorType = PasswordGeneratorType.CharSet, - Length = (uint)options.PasswordLength, - CharSet = new PwCharSet() - }; - - if (options.UpperCasePatternSelected) pwProfile.CharSet.Add(PwCharSet.UpperCase); - if (options.LowerCasePatternSelected) pwProfile.CharSet.Add(PwCharSet.LowerCase); - if (options.DigitsPatternSelected) pwProfile.CharSet.Add(PwCharSet.Digits); - if (options.SpecialPatternSelected) pwProfile.CharSet.Add(PwCharSet.Special); - if (options.MinusPatternSelected) pwProfile.CharSet.Add('-'); - if (options.UnderscorePatternSelected) pwProfile.CharSet.Add('_'); - if (options.SpacePatternSelected) pwProfile.CharSet.Add(' '); - if (options.BracketsPatternSelected) pwProfile.CharSet.Add(PwCharSet.Brackets); - - pwProfile.CharSet.Add(options.CustomChars); - - PwGenerator.Generate(out var password, pwProfile, null, new CustomPwGeneratorPool()); - - return password.ReadString(); - } - - public uint EstimatePasswordComplexity(string password) - { - return QualityEstimation.EstimatePasswordBits(password?.ToCharArray()); - } - - public byte[] GenerateKeyFile(byte[] additionalEntropy) - { - return KcpKeyFile.Create(additionalEntropy); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/Libs/Windows.winmd b/ModernKeePass.Infrastucture.12/Libs/Windows.winmd deleted file mode 100644 index d6498e8..0000000 Binary files a/ModernKeePass.Infrastucture.12/Libs/Windows.winmd and /dev/null differ diff --git a/ModernKeePass.Infrastucture.12/ModernKeePass.Infrastructure.csproj b/ModernKeePass.Infrastucture.12/ModernKeePass.Infrastructure.csproj deleted file mode 100644 index a4a5bf1..0000000 --- a/ModernKeePass.Infrastucture.12/ModernKeePass.Infrastructure.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - netstandard1.2 - - - - - - - - - - - - - - - Libs\Windows.winmd - true - - - - diff --git a/ModernKeePass.Infrastucture.12/UWP/StorageFileClient.cs b/ModernKeePass.Infrastucture.12/UWP/StorageFileClient.cs deleted file mode 100644 index 4337d42..0000000 --- a/ModernKeePass.Infrastucture.12/UWP/StorageFileClient.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; -using Windows.Storage; -using Windows.Storage.AccessCache; -using ModernKeePass.Application.Common.Interfaces; - -namespace ModernKeePass.Infrastructure.UWP -{ - public class StorageFileClient: IFileProxy - { - public async Task OpenBinaryFile(string path) - { - var file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(path); - var result = await FileIO.ReadBufferAsync(file); - return result.ToArray(); - } - - public async Task> OpenTextFile(string path) - { - var file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(path); - var result = await FileIO.ReadLinesAsync(file); - return result; - } - - public void ReleaseFile(string path) - { - StorageApplicationPermissions.FutureAccessList.Remove(path); - } - - public async Task WriteBinaryContentsToFile(string path, byte[] contents) - { - var file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(path); - await FileIO.WriteBytesAsync(file, contents); - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/UWP/UwpRecentFilesClient.cs b/ModernKeePass.Infrastucture.12/UWP/UwpRecentFilesClient.cs deleted file mode 100644 index 7dd750a..0000000 --- a/ModernKeePass.Infrastucture.12/UWP/UwpRecentFilesClient.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Windows.Storage.AccessCache; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Dtos; - -namespace ModernKeePass.Infrastructure.UWP -{ - public class UwpRecentFilesClient: IRecentProxy - { - private readonly StorageItemMostRecentlyUsedList _mru = StorageApplicationPermissions.MostRecentlyUsedList; - - public int EntryCount => _mru.Entries.Count; - - public async Task Get(string token) - { - var recentEntry = _mru.Entries.FirstOrDefault(e => e.Token == token); - var file = await _mru.GetFileAsync(token); - StorageApplicationPermissions.FutureAccessList.AddOrReplace(recentEntry.Metadata, file); - return new FileInfo - { - Name = file.DisplayName, - Path = recentEntry.Metadata - }; - } - - public async Task> GetAll() - { - var result = new List(); - foreach (var entry in _mru.Entries) - { - try - { - var recentItem = await Get(entry.Token); - result.Add(recentItem); - } - catch (Exception) - { - _mru.Remove(entry.Token); - } - } - return result; - } - - public async Task Add(FileInfo recentItem) - { - var file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(recentItem.Path); - _mru.Add(file, recentItem.Path); - } - - public void ClearAll() - { - for (var i = _mru.Entries.Count; i > 0; i--) - { - var entry = _mru.Entries[i]; - StorageApplicationPermissions.FutureAccessList.Remove(entry.Metadata); - _mru.Remove(entry.Token); - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/UWP/UwpResourceClient.cs b/ModernKeePass.Infrastucture.12/UWP/UwpResourceClient.cs deleted file mode 100644 index 6ddf960..0000000 --- a/ModernKeePass.Infrastucture.12/UWP/UwpResourceClient.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Windows.ApplicationModel.Resources; -using ModernKeePass.Application.Common.Interfaces; - -namespace ModernKeePass.Infrastructure.UWP -{ - public class UwpResourceClient: IResourceProxy - { - private const string ResourceFileName = "CodeBehind"; - private readonly ResourceLoader _resourceLoader = ResourceLoader.GetForCurrentView(); - - public string GetResourceValue(string key) - { - var resource = _resourceLoader.GetString($"/{ResourceFileName}/{key}"); - return resource; - } - } -} \ No newline at end of file diff --git a/ModernKeePass.Infrastucture.12/UWP/UwpSettingsClient.cs b/ModernKeePass.Infrastucture.12/UWP/UwpSettingsClient.cs deleted file mode 100644 index 612f1d7..0000000 --- a/ModernKeePass.Infrastucture.12/UWP/UwpSettingsClient.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using Windows.Foundation.Collections; -using Windows.Storage; -using ModernKeePass.Application.Common.Interfaces; - -namespace ModernKeePass.Infrastructure.UWP -{ - public class UwpSettingsClient : ISettingsProxy - { - private readonly IPropertySet _values = ApplicationData.Current.LocalSettings.Values; - - public T GetSetting(string property, T defaultValue = default) - { - try - { - return (T)Convert.ChangeType(_values[property], typeof(T)); - } - catch (InvalidCastException) - { - return defaultValue; - } - } - - public void PutSetting(string property, T value) - { - if (_values.ContainsKey(property)) - _values[property] = value; - else _values.Add(property, value); - } - } -} diff --git a/ModernKeePass/ModernKeePass.App.csproj b/ModernKeePass/ModernKeePass.App.csproj index 7027814..ac426e3 100644 --- a/ModernKeePass/ModernKeePass.App.csproj +++ b/ModernKeePass/ModernKeePass.App.csproj @@ -537,6 +537,20 @@ + + + {42353562-5e43-459c-8e3e-2f21e575261d} + ModernKeePass.Application + + + {9a0759f1-9069-4841-99e3-3bec44e17356} + ModernKeePass.Domain + + + {09577e4c-4899-45b9-bf80-1803d617ccae} + ModernKeePass.Infrastructure + + 12.0