diff --git a/Wallet.Avalonia/App.axaml.cs b/Wallet.Avalonia/App.axaml.cs index b91cbfa..4c4ca0b 100644 --- a/Wallet.Avalonia/App.axaml.cs +++ b/Wallet.Avalonia/App.axaml.cs @@ -62,7 +62,7 @@ public partial class App : Application } services.AddHandler(); - services.AddTransient(provider => Component.Register(provider, args => + services.AddTransient(provider => Component.Create(provider, args => { args.AddServices(services => { diff --git a/Wallet/IWalletComponent.cs b/Wallet/IWalletComponent.cs deleted file mode 100644 index 720bad0..0000000 --- a/Wallet/IWalletComponent.cs +++ /dev/null @@ -1,5 +0,0 @@ -using Toolkit.Foundation; - -namespace Wallet; - -public interface IWalletComponent : IComponent; \ No newline at end of file diff --git a/Wallet/IWalletFactory.cs b/Wallet/IWalletFactory.cs index 34fd703..61486ec 100644 --- a/Wallet/IWalletFactory.cs +++ b/Wallet/IWalletFactory.cs @@ -4,6 +4,6 @@ namespace Wallet { public interface IWalletFactory { - IComponentHost? Create(string name); + IComponentHost? Create(string key); } } \ No newline at end of file diff --git a/Wallet/WalletComponent.cs b/Wallet/WalletComponent.cs index 41a97fa..1d1bb0d 100644 --- a/Wallet/WalletComponent.cs +++ b/Wallet/WalletComponent.cs @@ -1,6 +1,20 @@ -using Toolkit.Foundation; +using Microsoft.Extensions.Hosting; +using Toolkit.Foundation; namespace Wallet; -public class WalletComponent(IComponentBuilder builder) : Component(builder), - IWalletComponent; \ No newline at end of file +public class WalletComponent(IHostEnvironment environment, + 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); + } +} \ No newline at end of file diff --git a/Wallet/WalletConnection.cs b/Wallet/WalletConnection.cs index 4a3ec14..0490e93 100644 --- a/Wallet/WalletConnection.cs +++ b/Wallet/WalletConnection.cs @@ -1,6 +1,6 @@ namespace Wallet; -public class WalletConnection(string connection) +public record WalletConnection(string connection) { private readonly string connection = connection; diff --git a/Wallet/WalletFactory.cs b/Wallet/WalletFactory.cs index b3a0af3..0211388 100644 --- a/Wallet/WalletFactory.cs +++ b/Wallet/WalletFactory.cs @@ -5,9 +5,10 @@ namespace Wallet; public class WalletFactory(IComponentFactory componentFactory) : IWalletFactory { - public IComponentHost? Create(string name) + public IComponentHost? Create(string key) { - if (componentFactory.Create($"Wallet:{name}", new WalletConfiguration()) is IComponentHost host) + if (componentFactory.Create($"Wallet:{key}", + new WalletConfiguration()) is IComponentHost host) { return host; } diff --git a/Wallet/WalletInitializer.cs b/Wallet/WalletInitializer.cs index c64fe2c..90b62fc 100644 --- a/Wallet/WalletInitializer.cs +++ b/Wallet/WalletInitializer.cs @@ -11,7 +11,7 @@ public class WalletInitializer(IEnumerable configuration in configurations) { - if (componentFactory.Create(configuration.Section, configuration.Value) is IComponentHost host) {