Add support for self scope
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
@@ -14,4 +15,7 @@ public partial class AddItemActionViewModel(IServiceProvider provider,
|
||||
|
||||
[ObservableProperty]
|
||||
private string named = $"{named}";
|
||||
|
||||
[RelayCommand]
|
||||
public async Task Invoke() => await Publisher.Publish(new Test());
|
||||
}
|
||||
@@ -4,7 +4,8 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class AddItemViewModel :
|
||||
ObservableCollectionViewModel<IItemViewModel>
|
||||
ObservableCollectionViewModel<IItemViewModel>,
|
||||
INotificationHandler<Test>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string named;
|
||||
@@ -36,4 +37,9 @@ public partial class AddItemViewModel :
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public Task Handle(Test args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record Test;
|
||||
|
||||
public partial class ConfirmItemActionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) : ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer);
|
||||
IDisposer disposer) : ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[RelayCommand]
|
||||
public async Task Invoke() => await Publisher.Publish(new Test());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContaienrConnection(string connection)
|
||||
public class ContainerConnection(string connection)
|
||||
{
|
||||
private readonly string connection = connection;
|
||||
|
||||
@@ -6,7 +6,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ContainerFactory(IContainer<ContaienrConnection> connection,
|
||||
public class ContainerFactory(IContainer<ContainerConnection> connection,
|
||||
IHostEnvironment environment,
|
||||
IServiceProvider provider) :
|
||||
IContainer
|
||||
@@ -14,7 +14,7 @@ public class ContainerFactory(IContainer<ContaienrConnection> connection,
|
||||
public async Task<bool> Create(string name,
|
||||
SecurityKey key)
|
||||
{
|
||||
connection.Set(new ContaienrConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
connection.Set(new ContainerConnection($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
$".vault;Mode=ReadWriteCreate;Pooling=false;Password={Convert.ToBase64String(key.DecryptedKey)}"));
|
||||
|
||||
IDbContextFactory<VaultDbContext> dbContextFactory = provider.GetRequiredService<IDbContextFactory<VaultDbContext>>();
|
||||
|
||||
@@ -15,7 +15,7 @@ public partial class ContainerHeaderViewModel : ObservableCollectionViewModel<st
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<AddItemActionViewModel>();
|
||||
Add<AddItemActionViewModel>(scope: true);
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
@@ -13,7 +13,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
NamedComponent named,
|
||||
string name,
|
||||
string description) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<Test>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? description = description;
|
||||
@@ -27,4 +28,9 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(Test args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user