Add some initial navigation route handlers

This commit is contained in:
Daniel Clark
2022-12-09 08:58:26 +00:00
parent fdcce769e5
commit 4c8fd3dae4
34 changed files with 403 additions and 343 deletions
@@ -1,9 +1,17 @@
using Microsoft.Extensions.DependencyInjection;
using Mediator;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Toolkit.Foundation
{
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddHandler<TRequestHandler>(this IServiceCollection serviceCollection)
{
serviceCollection.TryAdd(new ServiceDescriptor(typeof(TRequestHandler), typeof(TRequestHandler), ServiceLifetime.Transient));
return serviceCollection;
}
public static IServiceCollection AddFoundation(this IServiceCollection serviceCollection)
{
serviceCollection.AddSingleton<IServiceFactory>(provider => new ServiceFactory(provider.GetService, (instanceType, parameters) => ActivatorUtilities.CreateInstance(provider, instanceType, parameters!)));