mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Most services are implemented as command/queries
Code cleanup
This commit is contained in:
@@ -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<Entity> Ciphers => _cryptographyClient.Ciphers;
|
||||
|
||||
public IEnumerable<Entity> KeyDerivations => _cryptographyClient.KeyDerivations;
|
||||
|
||||
public IEnumerable<string> CompressionAlgorithms => _cryptographyClient.CompressionAlgorithms;
|
||||
|
||||
public CryptographyService(ICryptographyClient cryptographyClient)
|
||||
{
|
||||
_cryptographyClient = cryptographyClient;
|
||||
}
|
||||
}
|
||||
}
|
@@ -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<byte[]> OpenBinaryFile(string path)
|
||||
{
|
||||
return _fileProxy.OpenBinaryFile(path);
|
||||
}
|
||||
|
||||
public Task WriteBinaryContentsToFile(string path, byte[] contents)
|
||||
{
|
||||
return _fileProxy.WriteBinaryContentsToFile(path, contents);
|
||||
}
|
||||
|
||||
public Task<IList<string>> OpenTextFile(string path)
|
||||
{
|
||||
return _fileProxy.OpenTextFile(path);
|
||||
}
|
||||
|
||||
public void ReleaseFile(string path)
|
||||
{
|
||||
_fileProxy.ReleaseFile(path);
|
||||
}
|
||||
}
|
||||
}
|
@@ -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<ImportFormat, IImportFormat> _importFormatProviders;
|
||||
|
||||
public ImportService(Func<ImportFormat, IImportFormat> 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"];
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
@@ -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<FileInfo> Get(string token)
|
||||
{
|
||||
return await _recentProxy.Get(token);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FileInfo>> GetAll()
|
||||
{
|
||||
return await _recentProxy.GetAll();
|
||||
}
|
||||
|
||||
public async Task Add(FileInfo recentItem)
|
||||
{
|
||||
await _recentProxy.Add(recentItem);
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
_recentProxy.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -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<T>(string property, T defaultValue = default)
|
||||
{
|
||||
return _settingsProxy.GetSetting<T>(property, defaultValue);
|
||||
}
|
||||
|
||||
public void PutSetting<T>(string property, T value)
|
||||
{
|
||||
_settingsProxy.PutSetting<T>(property, value);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user