Switch out dotnet ctk messenger for source gen Meditor
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Data.Converters;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
{
|
||||
|
||||
public static class EventArgsExtensions
|
||||
{
|
||||
public static dynamic? GetEventArguments(this EventArgs args, string? path, IValueConverter? converter, object? converterParameter)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using Avalonia.Platform;
|
||||
using Avalonia;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
{
|
||||
public static class IHostBuilderExtensions
|
||||
{
|
||||
public static IHostBuilder ConfigureTemplates(this IHostBuilder hostBuilder, Action<ITemplateBuilder> builderDelegate)
|
||||
{
|
||||
hostBuilder.ConfigureServices((hostBuilderContext, serviceCollection) =>
|
||||
{
|
||||
TemplateBuilder? builder = new();
|
||||
builderDelegate?.Invoke(builder);
|
||||
|
||||
serviceCollection.TryAddSingleton(builder.Descriptors);
|
||||
serviceCollection.TryAddSingleton<ITemplateDescriptorProvider, TemplateDescriptorProvider>();
|
||||
serviceCollection.TryAddSingleton<ITemplateFactory, TemplateFactory>();
|
||||
serviceCollection.TryAddSingleton<INamedTemplateFactory, NamedTemplateFactory>();
|
||||
serviceCollection.TryAddSingleton<ITypedDataTemplateFactory, TypedDataTemplateFactory>();
|
||||
serviceCollection.TryAddSingleton<INamedDataTemplateFactory, NamedDataTemplateFactory>();
|
||||
serviceCollection.TryAddSingleton<ITemplateSelector, TemplateSelector>();
|
||||
|
||||
foreach (ITemplateDescriptor? descriptor in builder.Descriptors)
|
||||
{
|
||||
serviceCollection.Add(new ServiceDescriptor(descriptor.TemplateType, descriptor.TemplateType, descriptor.Lifetime));
|
||||
serviceCollection.Add(new ServiceDescriptor(descriptor.DataType, descriptor.DataType, descriptor.Lifetime));
|
||||
}
|
||||
});
|
||||
|
||||
return hostBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
{
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddNavigation(this IServiceCollection serviceCollection)
|
||||
{
|
||||
serviceCollection.TryAddSingleton<INavigationRouteDescriptorCollection, NavigationRouteDescriptorCollection>();
|
||||
serviceCollection.TryAddSingleton<INavigationRouter, NavigationRouter>();
|
||||
|
||||
return serviceCollection;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user