Amend compoments to be keyed based
This commit is contained in:
@@ -62,7 +62,7 @@ public partial class App : Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
services.AddHandler<WalletActivatedHandler>();
|
services.AddHandler<WalletActivatedHandler>();
|
||||||
services.AddTransient<IWalletComponent>(provider => Component.Register<WalletComponent>(provider, args =>
|
services.AddTransient(provider => Component.Create<WalletComponent>(provider, args =>
|
||||||
{
|
{
|
||||||
args.AddServices(services =>
|
args.AddServices(services =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
using Toolkit.Foundation;
|
|
||||||
|
|
||||||
namespace Wallet;
|
|
||||||
|
|
||||||
public interface IWalletComponent : IComponent;
|
|
||||||
@@ -4,6 +4,6 @@ namespace Wallet
|
|||||||
{
|
{
|
||||||
public interface IWalletFactory
|
public interface IWalletFactory
|
||||||
{
|
{
|
||||||
IComponentHost? Create(string name);
|
IComponentHost? Create(string key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,20 @@
|
|||||||
using Toolkit.Foundation;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
namespace Wallet;
|
namespace Wallet;
|
||||||
|
|
||||||
public class WalletComponent(IComponentBuilder builder) : Component(builder),
|
public class WalletComponent(IHostEnvironment environment,
|
||||||
IWalletComponent;
|
IComponentBuilder builder) :
|
||||||
|
Component(builder)
|
||||||
|
{
|
||||||
|
public override IComponentBuilder Configuring(string key,
|
||||||
|
IComponentBuilder builder)
|
||||||
|
{
|
||||||
|
builder.SetComponentConfiguration(args =>
|
||||||
|
{
|
||||||
|
args.ContentRoot = Path.Combine(environment.ContentRootPath, key.Replace(":", "\\"));
|
||||||
|
});
|
||||||
|
|
||||||
|
return base.Configuring(key, builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Wallet;
|
namespace Wallet;
|
||||||
|
|
||||||
public class WalletConnection(string connection)
|
public record WalletConnection(string connection)
|
||||||
{
|
{
|
||||||
private readonly string connection = connection;
|
private readonly string connection = connection;
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ namespace Wallet;
|
|||||||
public class WalletFactory(IComponentFactory componentFactory) :
|
public class WalletFactory(IComponentFactory componentFactory) :
|
||||||
IWalletFactory
|
IWalletFactory
|
||||||
{
|
{
|
||||||
public IComponentHost? Create(string name)
|
public IComponentHost? Create(string key)
|
||||||
{
|
{
|
||||||
if (componentFactory.Create<IWalletComponent, WalletConfiguration>($"Wallet:{name}", new WalletConfiguration()) is IComponentHost host)
|
if (componentFactory.Create<WalletComponent, WalletConfiguration>($"Wallet:{key}",
|
||||||
|
new WalletConfiguration()) is IComponentHost host)
|
||||||
{
|
{
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class WalletInitializer(IEnumerable<IConfigurationDescriptor<WalletConfig
|
|||||||
{
|
{
|
||||||
foreach (IConfigurationDescriptor<WalletConfiguration> configuration in configurations)
|
foreach (IConfigurationDescriptor<WalletConfiguration> configuration in configurations)
|
||||||
{
|
{
|
||||||
if (componentFactory.Create<IWalletComponent,
|
if (componentFactory.Create<WalletComponent,
|
||||||
WalletConfiguration>(configuration.Section, configuration.Value)
|
WalletConfiguration>(configuration.Section, configuration.Value)
|
||||||
is IComponentHost host)
|
is IComponentHost host)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user