using Hyperbar.Desktop.Contextual; using Hyperbar.Desktop.Controls; using Hyperbar.Desktop.Primary; using Hyperbar.Lifecycles; using Hyperbar.Templates; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.UI.Xaml; using System; using System.Collections.Generic; namespace Hyperbar.Desktop; public class AppConfiguration { } public partial class App : Application { public App() => InitializeComponent(); protected override async void OnLaunched(LaunchActivatedEventArgs args) { base.OnLaunched(args); IHost? host = Host.CreateDefaultBuilder() .UseContentRoot(AppContext.BaseDirectory) .ConfigureAppConfiguration(config => { config.SetBasePath(AppContext.BaseDirectory); config.AddJsonFile("Settings.json", true); config.Build(); }) .ConfigureServices((context, services) => { services.AddHostedService(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddDataTemplate(); services.AddCommand(""); services.AddCommand(""); services.AddTransient(provider => { static IEnumerable Resolve(IServiceProvider services) { foreach (ICommandContext commandContext in services.GetServices()) { if (commandContext.ServiceProvider.GetService() is ICommandViewModel commandViewModel) { yield return commandViewModel; } } } return Resolve(provider); }); services.ConfigureWritableOptions(); }) .Build(); await host.RunAsync(); } }