mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
30 lines
968 B
C#
30 lines
968 B
C#
using System.Threading.Tasks;
|
|
using MediatR;
|
|
using ModernKeePass.Application.Common.Interfaces;
|
|
using ModernKeePass.Domain.Exceptions;
|
|
|
|
namespace ModernKeePass.Application.Database.Queries.ReOpenDatabase
|
|
{
|
|
public class ReOpenDatabaseQuery: IRequest
|
|
{
|
|
public class ReOpenDatabaseQueryHandler : IAsyncRequestHandler<ReOpenDatabaseQuery>
|
|
{
|
|
private readonly IDatabaseProxy _database;
|
|
private readonly IFileProxy _file;
|
|
|
|
public ReOpenDatabaseQueryHandler(IDatabaseProxy database, IFileProxy file)
|
|
{
|
|
_database = database;
|
|
_file = file;
|
|
}
|
|
|
|
public async Task Handle(ReOpenDatabaseQuery request)
|
|
{
|
|
if (!_database.IsOpen) throw new DatabaseClosedException();
|
|
|
|
var file = await _file.OpenBinaryFile(_database.FileAccessToken);
|
|
await _database.ReOpen(file);
|
|
}
|
|
}
|
|
}
|
|
} |