bunch of fixes
This commit is contained in:
@@ -1,25 +1,28 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateVaultHandler(IVaultComponentFactory vaultComponentFactory) :
|
||||
public class CreateVaultHandler(IVaultComponentFactory componentFactory) :
|
||||
IHandler<Create<Vault>, bool>
|
||||
{
|
||||
public Task<bool> Handle(Create<Vault> args,
|
||||
public async Task<bool> Handle(Create<Vault> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is Vault vault && vault.Name is { Length: > 0 } name && vault.Password is { Length: > 0 } password)
|
||||
if (args.Value is Vault vault && vault.Name is { Length: > 0 } name &&
|
||||
vault.Password is { Length: > 0 } password)
|
||||
{
|
||||
if (vaultComponentFactory.Create(name) is IComponentHost host)
|
||||
if (componentFactory.Create(name) is IComponentHost host)
|
||||
{
|
||||
IVaultFactory factory = host.Services.GetRequiredService<IVaultFactory>();
|
||||
factory.Create(name, password);
|
||||
|
||||
return Task.FromResult(true);
|
||||
IVaultInitializer initializer = host.Services.GetRequiredService<IVaultInitializer>();
|
||||
if (await initializer.Initialize(name, password))
|
||||
{
|
||||
host.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user