diff --git a/Wallet/CreateWalletHandler.cs b/Wallet/CreateWalletHandler.cs index 29aafc0..7a3a911 100644 --- a/Wallet/CreateWalletHandler.cs +++ b/Wallet/CreateWalletHandler.cs @@ -5,6 +5,7 @@ using Toolkit.Foundation; namespace Wallet; public class CreateWalletHandler(IWalletHostFactory componentFactory, + IWalletHostCollection wallets, IPublisher publisher) : IHandler>, bool> { @@ -23,9 +24,10 @@ public class CreateWalletHandler(IWalletHostFactory componentFactory, IWalletFactory walletFactory = host.Services.GetRequiredService(); if (await walletFactory.Create(name, password, imageDescriptor)) { + wallets.Add(host); host.Start(); - publisher.Publish(Activated.As(new Wallet(host))); + publisher.Publish(Activated.As(new Wallet(host))); return true; } } diff --git a/Wallet/WalletActivatedHandler.cs b/Wallet/WalletActivatedHandler.cs index 22b78e4..32145ed 100644 --- a/Wallet/WalletActivatedHandler.cs +++ b/Wallet/WalletActivatedHandler.cs @@ -3,7 +3,7 @@ using Toolkit.Foundation; namespace Wallet; -public class WalletActivatedHandler(IWalletHostCollection Wallets, +public class WalletActivatedHandler(IWalletHostCollection wallets, IPublisher publisher) : INotificationHandler>> { @@ -11,8 +11,7 @@ public class WalletActivatedHandler(IWalletHostCollection Wallets, { if (args.Sender is Wallet wallet && wallet.Value is IComponentHost host) { - List sortedWallets = [.. Wallets, host]; - sortedWallets = [.. sortedWallets.OrderBy(x => x.Services.GetRequiredService>() is + List sortedWallets = [.. wallets.OrderBy(x => x.Services.GetRequiredService>() is IConfigurationDescriptor descriptor ? descriptor.Name : null)]; int index = sortedWallets.IndexOf(host); diff --git a/Wallet/WalletCollectionInitializer.cs b/Wallet/WalletCollectionInitializer.cs index 4624aeb..bfa2546 100644 --- a/Wallet/WalletCollectionInitializer.cs +++ b/Wallet/WalletCollectionInitializer.cs @@ -5,7 +5,7 @@ namespace Wallet; public class WalletCollectionInitializer(IHostEnvironment environment, IComponentFactory componentFactory, - IWalletHostCollection Wallets) : + IWalletHostCollection wallets) : IInitialization { public void Initialize() @@ -25,7 +25,7 @@ public class WalletCollectionInitializer(IHostEnvironment environment, WalletConfiguration>(section, new WalletConfiguration()) is IComponentHost host) { - Wallets.Add(host); + wallets.Add(host); host.Start(); } }