From b89f21b3ca491b24f826c22fa1e540572f6ffaa9 Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Mon, 29 Apr 2024 21:42:04 +0100 Subject: [PATCH] encyption wip --- Toolkit.Foundation/ComponentConfiguration.cs | 4 +--- Toolkit.Foundation/ComponentFactory.cs | 8 +++++--- Toolkit.Foundation/IComponentFactory.cs | 7 ++++--- Toolkit.Foundation/Initialized.cs | 10 ---------- Toolkit.Foundation/Open.cs | 10 ++++++++++ 5 files changed, 20 insertions(+), 19 deletions(-) delete mode 100644 Toolkit.Foundation/Initialized.cs create mode 100644 Toolkit.Foundation/Open.cs 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