This commit is contained in:
TheXamlGuy
2024-09-27 21:25:36 +01:00
parent bd577975b2
commit 928969f39f
5 changed files with 16 additions and 11 deletions
+7
View File
@@ -9,6 +9,7 @@ public class ComponentFactory(IServiceProvider provider,
{
public IComponentHost? Create<TComponent, TConfiguration>(string key,
TConfiguration? configuration = null,
Action<IComponentBuilder>? builderDelegate = null,
Action<IServiceCollection>? servicesDelegate = null)
where TComponent : IComponent
where TConfiguration :
@@ -17,6 +18,12 @@ public class ComponentFactory(IServiceProvider provider,
if (provider.GetRequiredService<TComponent>() is TComponent component)
{
IComponentBuilder builder = component.Configure(key);
if (builderDelegate is not null)
{
builderDelegate(builder);
}
builder.AddServices(services =>
{
services.AddTransient(_ =>