Load wallets from self contained folders
This commit is contained in:
@@ -1,18 +1,23 @@
|
|||||||
using Toolkit.Foundation;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
namespace Wallet;
|
namespace Wallet;
|
||||||
|
|
||||||
public class WalletInitializer(IEnumerable<IConfigurationDescriptor<WalletConfiguration>> configurations,
|
public class WalletInitializer(IHostingEnvironment environment, IEnumerable<IConfigurationDescriptor<WalletConfiguration>> configurations,
|
||||||
IComponentFactory componentFactory,
|
IComponentFactory componentFactory,
|
||||||
IWalletHostCollection Wallets) :
|
IWalletHostCollection Wallets) :
|
||||||
IInitialization
|
IInitialization
|
||||||
{
|
{
|
||||||
public async Task Initialize()
|
public async Task Initialize()
|
||||||
{
|
{
|
||||||
foreach (IConfigurationDescriptor<WalletConfiguration> configuration in configurations)
|
foreach (string wallet in Directory.EnumerateDirectories(Path.Combine(environment.ContentRootPath, "Wallet")))
|
||||||
{
|
{
|
||||||
|
string name = Path.GetFileName(wallet);
|
||||||
|
string section = $"Wallet:{name}";
|
||||||
|
|
||||||
if (componentFactory.Create<WalletComponent,
|
if (componentFactory.Create<WalletComponent,
|
||||||
WalletConfiguration>(configuration.Section, configuration.Value)
|
WalletConfiguration>(section)
|
||||||
is IComponentHost host)
|
is IComponentHost host)
|
||||||
{
|
{
|
||||||
Wallets.Add(host);
|
Wallets.Add(host);
|
||||||
|
|||||||
Reference in New Issue
Block a user