switched to valuetuples for exhanging tokens

This commit is contained in:
TheXamlGuy
2024-05-27 20:43:18 +01:00
parent 1be1399511
commit 9535f75835
17 changed files with 85 additions and 94 deletions
+8 -6
View File
@@ -4,19 +4,21 @@ using Toolkit.Foundation;
namespace Bitvault;
public class CreatedItemHandler(IServiceProvider serviceProvider,
ICache<Item> cache,
ICache<Item<(Guid, string)>> cache,
IPublisher publisher) :
INotificationHandler<CreatedEventArgs<Item>>
INotificationHandler<CreatedEventArgs<Item<(Guid, string)>>>
{
public Task Handle(CreatedEventArgs<Item> args)
public Task Handle(CreatedEventArgs<Item<(Guid, string)>> args)
{
if (args.Value is Item item)
if (args.Value is Item<(Guid, string)> item)
{
(Guid id, string name) = item.Value;
IServiceScope serviceScope = serviceProvider.CreateScope();
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
IValueStore<Item> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item>>();
IValueStore<Item<(Guid, string)>> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item<(Guid, string)>>>();
if (serviceFactory.Create<ItemNavigationViewModel>(item.Id, item.Name, "Description", true)
if (serviceFactory.Create<ItemNavigationViewModel>(id, name, "Description", true)
is ItemNavigationViewModel viewModel)
{
cache.Add(item);