using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Toolkit.Foundation; using Toolkit.UI.Controls.Avalonia; namespace Toolkit.Avalonia; public static class IServiceCollectionExtensions { public static IServiceCollection AddAvalonia(this IServiceCollection services) { services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddHandler(); services.AddHandler(); services.AddHandler(); services.AddHandler(nameof(IClassicDesktopStyleApplicationLifetime)); services.AddHandler(nameof(ISingleViewApplicationLifetime)); services.AddHandler(nameof(ContentControl)); services.AddHandler(nameof(Frame)); services.AddHandler(nameof(ContentDialog)); services.AddHandler(nameof(TaskDialog)); services.AddScoped(provider => new NavigationRegionCollection { { typeof(IClassicDesktopStyleApplicationLifetime), typeof(IClassicDesktopStyleApplicationLifetime) }, { typeof(ISingleViewApplicationLifetime), typeof(ISingleViewApplicationLifetime) } }); services.AddTransient((Func>)(provider => new ProxyServiceCollection(services => { services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddSingleton(provider.GetRequiredService()); services.AddTransient(); services.AddTransient(); services.AddHandler(); services.AddHandler(); services.AddHandler(); services.AddHandler(nameof(ContentControl)); services.AddHandler(nameof(Frame)); services.AddHandler(nameof(ContentDialog)); services.AddHandler(nameof(TaskDialog)); }))); return services; } }