Files
Toolkit2/Toolkit.WinUI/IServiceCollectionExtensions.cs
T
Dan Clark 66d61a3917 Fixes
2025-02-11 17:59:16 +00:00

30 lines
1.1 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml.Controls;
using Toolkit.Foundation;
namespace Toolkit.WinUI;
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddWinUI(this IServiceCollection services)
{
services.AddSingleton<IDispatcher>(provider => new WinUIDispatcher(DispatcherQueue.GetForCurrentThread()));
services.AddTransient<IDispatcherTimerFactory, DispatcherTimerFactory>();
services.AddSingleton<IWindowRegistry, WindowRegistry>();
services.AddTransient<IContentTemplate, ContentTemplate>();
services.AddTransient<INavigationRegion, NavigationRegion>();
services.AddHandlerScoped<NavigateTemplateEventArgs, ContentControlHandler>(nameof(ContentControl));
services.AddHandlerScoped<NavigateTemplateEventArgs, ContentDialogHandler>(nameof(ContentDialog));
services.AddTransient((Func<IServiceProvider, IProxyServiceCollection<IComponentBuilder>>)(provider =>
new ProxyServiceCollection<IComponentBuilder>(services =>
{
})));
return services;
}
}