diff --git a/Toolkit.Foundation/ComponentConfiguration.cs b/Toolkit.Foundation/ComponentConfiguration.cs index 1bf75b0..907c0a7 100644 --- a/Toolkit.Foundation/ComponentConfiguration.cs +++ b/Toolkit.Foundation/ComponentConfiguration.cs @@ -1,5 +1,3 @@ namespace Toolkit.Foundation; -public record ComponentConfiguration -{ -} \ No newline at end of file +public record ComponentConfiguration; \ No newline at end of file diff --git a/Toolkit.Foundation/ComponentFactory.cs b/Toolkit.Foundation/ComponentFactory.cs index b23d95b..d341915 100644 --- a/Toolkit.Foundation/ComponentFactory.cs +++ b/Toolkit.Foundation/ComponentFactory.cs @@ -7,9 +7,11 @@ public class ComponentFactory(IServiceProvider provider, IComponentScopeCollection scopes) : IComponentFactory { - public IComponentHost? Create(string name, - ComponentConfiguration configuration, Action? servicesDelegate = null) + public IComponentHost? Create(string name, + TConfiguration configuration, + Action? servicesDelegate = null) where TComponent : IComponent + where TConfiguration : ComponentConfiguration, new() { if (provider.GetRequiredService() is TComponent component) { @@ -43,7 +45,7 @@ public class ComponentFactory(IServiceProvider provider, } }); - builder.AddConfiguration(name, configuration); + builder.AddConfiguration(name, configuration); IComponentHost host = builder.Build(); scopes.Add(new ComponentScopeDescriptor(name, diff --git a/Toolkit.Foundation/IComponentFactory.cs b/Toolkit.Foundation/IComponentFactory.cs index 6380136..451f30f 100644 --- a/Toolkit.Foundation/IComponentFactory.cs +++ b/Toolkit.Foundation/IComponentFactory.cs @@ -4,7 +4,8 @@ namespace Toolkit.Foundation; public interface IComponentFactory { - IComponentHost? Create(string name, - ComponentConfiguration configuration, Action? servicesDelegate = null) - where TComponent : IComponent; + IComponentHost? Create(string name, + TConfiguration configuration, Action? servicesDelegate = null) + where TComponent : IComponent + where TConfiguration : ComponentConfiguration, new(); } \ No newline at end of file diff --git a/Toolkit.Foundation/Initialized.cs b/Toolkit.Foundation/Initialized.cs deleted file mode 100644 index 6302662..0000000 --- a/Toolkit.Foundation/Initialized.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Toolkit.Foundation; - -public record Initialized(TValue Value); - -public record Initialized -{ - public static Initialized As(TValue value) => new(value); - - public static Initialized As() where TValue : new() => new(new TValue()); -} \ No newline at end of file diff --git a/Toolkit.Foundation/Open.cs b/Toolkit.Foundation/Open.cs new file mode 100644 index 0000000..7e41b12 --- /dev/null +++ b/Toolkit.Foundation/Open.cs @@ -0,0 +1,10 @@ +namespace Toolkit.Foundation; + +public record Open(TValue Value); + +public record Open +{ + public static Open As(TValue value) => new(value); + + public static Open As() where TValue : new() => new(new TValue()); +} \ No newline at end of file