Files
Walleby/Wallet/WalletCollectionInitializer.cs
T
2024-06-29 22:06:08 +01:00

33 lines
907 B
C#

using Microsoft.Extensions.Hosting;
using Toolkit.Foundation;
namespace Wallet;
public class WalletCollectionInitializer(IHostEnvironment environment,
IComponentFactory componentFactory,
IWalletHostCollection Wallets) :
IInitialization
{
public void Initialize()
{
string path = Path.Combine(environment.ContentRootPath, "Wallet");
if (!Directory.Exists(path))
{
return;
}
foreach (string wallet in Directory.EnumerateDirectories(path))
{
string name = Path.GetFileName(wallet);
string section = $"Wallet:{name}";
if (componentFactory.Create<WalletComponent,
WalletConfiguration>(section, new WalletConfiguration())
is IComponentHost host)
{
Wallets.Add(host);
host.Start();
}
}
}
}