Rename projects to better structure it. The aim is to try and keep it not dependant on the type of UI framework it uses thus allowing us to switch to another UI framework if we need later...

This commit is contained in:
TheXamlGuy
2024-01-06 08:49:12 +00:00
parent b380f06fbf
commit 3e88950669
67 changed files with 211 additions and 196 deletions
@@ -0,0 +1,29 @@
using Hyperbar.Lifecycles;
using Hyperbar.Templates;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Hyperbar.Windows
{
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddCommand<TCommandBuilder>(this IServiceCollection services,
string key)
where TCommandBuilder :
ICommandWidgetBuilder, new()
{
TCommandBuilder builder = new();
IHost? host = new HostBuilder()
.ConfigureServices(isolatedServices =>
{
isolatedServices.AddTransient<ITemplateFactory, TemplateFactory>();
isolatedServices.AddTransient<ITemplateGeneratorFactory, TemplateGeneratorFactory>();
builder.Create(isolatedServices);
}).Build();
services.AddTransient<ICommandWidgetContext>(provider => new CommandWidgetContext(host.Services));
return services;
}
}
}