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
+7 -7
View File
@@ -5,20 +5,20 @@ namespace Bitvault;
public class ModifiedItemHandler(IServiceProvider serviceProvider,
IPublisher publisher) :
INotificationHandler<ModifiedEventArgs<Item>>
INotificationHandler<ModifiedEventArgs<Item<(Guid, string)>>>
{
public Task Handle(ModifiedEventArgs<Item> args)
public Task Handle(ModifiedEventArgs<Item<(Guid, string)>> args)
{
Item oldItem = args.OldView;
Item newItem = args.NewValue;
Item<(Guid, string)> oldItem = args.OldView;
Item<(Guid, string)> newItem = args.NewValue;
ICache<Item> cache = serviceProvider.GetRequiredService<ICache<Item>>();
if (cache.TryGetValue(oldItem, out Item? cachedItem))
ICache<Item<(Guid, string)>> cache = serviceProvider.GetRequiredService<ICache<Item<(Guid, string)>>>();
if (cache.TryGetValue(oldItem, out Item<(Guid, string)>? cachedItem))
{
if (cachedItem is not null)
{
IServiceScope serviceScope = serviceProvider.CreateScope();
IValueStore<Item> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item>>();
IValueStore<Item<(Guid, string)>> valueStore = serviceScope.ServiceProvider.GetRequiredService<IValueStore<Item<(Guid, string)>>>();
int oldIndex = cache.IndexOf(cachedItem);
cache.Remove(cachedItem);