Full removal of SourceGen Meditor. Will revisit in good time.
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
||||||
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview4" />
|
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview4" />
|
||||||
<PackageReference Include="Mediator.Abstractions" Version="2.1.0-preview.5" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Foundation\Foundation.csproj" />
|
<ProjectReference Include="..\Foundation\Foundation.csproj" />
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Mediator;
|
|
||||||
using Toolkit.Framework.Foundation;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Toolkit.Framework.Avalonia;
|
|||||||
|
|
||||||
public static class IHostBuilderExtensions
|
public static class IHostBuilderExtensions
|
||||||
{
|
{
|
||||||
public static IHostBuilder ConfigureTemplates(this IHostBuilder hostBuilder, Action<IContentTemplateBuilder> builderDelegate)
|
public static IHostBuilder ConfigureContents(this IHostBuilder hostBuilder, Action<IContentTemplateBuilder> builderDelegate)
|
||||||
{
|
{
|
||||||
hostBuilder.ConfigureServices((hostBuilderContext, serviceCollection) =>
|
hostBuilder.ConfigureServices((hostBuilderContext, serviceCollection) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Data;
|
using Avalonia.Data;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Mediator;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Toolkit.Framework.Foundation;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Data;
|
using Avalonia.Data;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Mediator;
|
|
||||||
using Toolkit.Framework.Foundation;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Avalonia.Controls.Primitives;
|
|||||||
using Avalonia.Data;
|
using Avalonia.Data;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Mediator;
|
|
||||||
using Toolkit.Framework.Foundation;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Mediator;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Mediator;
|
|
||||||
using Toolkit.Framework.Foundation;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using FluentAvalonia.UI.Navigation;
|
using FluentAvalonia.UI.Navigation;
|
||||||
using Mediator;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Mediator;
|
|
||||||
using Toolkit.Framework.Foundation;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Mediator;
|
|
||||||
using Toolkit.Framework.Foundation;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Mediator;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Mediator;
|
|
||||||
using Toolkit.Framework.Foundation;
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Avalonia;
|
namespace Toolkit.Framework.Avalonia;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Framework.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public record ConfigurationChanged<TConfiguration>(TConfiguration Configuration) where TConfiguration : class;
|
public record ConfigurationChanged<TConfiguration>(TConfiguration Configuration) : INotification where TConfiguration : class;
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public class ConfigurationInitializer<TConfiguration> : IInitializable where TConfiguration : class, new()
|
public class ConfigurationInitializer<TConfiguration> : IInitializable where TConfiguration : class, new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public record Write<TConfiguration>(Action<TConfiguration> UpdateDelegate) : IRequest where TConfiguration : class;
|
public record Write<TConfiguration>(Action<TConfiguration> UpdateDelegate) : IRequest where TConfiguration : class;
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public class WriteHandler<TConfiguration> : IRequestHandler<Write<TConfiguration>> where TConfiguration : class
|
public class WriteHandler<TConfiguration> : IRequestHandler<Write<TConfiguration>> where TConfiguration : class
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public record Content : IRequest<object?>
|
public record Content : IRequest<object?>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class NamedContentFactory : INamedContentFactory
|
|||||||
this.serviceFactory = serviceFactory;
|
this.serviceFactory = serviceFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual object? Create(string name, params object[] parameters)
|
public virtual object? Create(string name, params object?[] parameters)
|
||||||
{
|
{
|
||||||
if (cache.TryGetValue(name, out object? data))
|
if (cache.TryGetValue(name, out object? data))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class TypedContentFactory : ITypedContentFactory
|
|||||||
this.serviceFactory = serviceFactory;
|
this.serviceFactory = serviceFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual object? Create(Type type, params object[] parameters)
|
public object? Create(Type type, params object?[] parameters)
|
||||||
{
|
{
|
||||||
if (cache.TryGetValue(type, out object? data))
|
if (cache.TryGetValue(type, out object? data))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Mediator;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|||||||
@@ -9,15 +9,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="JsonCons.JsonPath" Version="1.1.0" />
|
|
||||||
<PackageReference Include="JsonCons.Utilities" Version="1.0.0" />
|
|
||||||
<PackageReference Include="JsonPatch.Net" Version="2.0.4" />
|
<PackageReference Include="JsonPatch.Net" Version="2.0.4" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||||
<PackageReference Include="Mediator.Abstractions" Version="2.1.0-preview.5" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Mediator;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public class CommandClassHandlerWrapper<TRequest, TResponse> where TRequest : class, ICommand<TResponse>
|
public class CommandClassHandlerWrapper<TRequest, TResponse> where TRequest : class, ICommand<TResponse>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface ICommand<out TResponse> : IMessage { }
|
||||||
|
public interface ICommand : ICommand<Unit> { }
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface ICommandHandler<in TCommand> : ICommandHandler<TCommand, Unit> where TCommand : ICommand<Unit> { }
|
||||||
|
|
||||||
|
public interface ICommandHandler<in TCommand, TResponse> where TCommand : ICommand<TResponse>
|
||||||
|
{
|
||||||
|
ValueTask<TResponse> Handle(TCommand command, CancellationToken cancellationToken);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IMediator
|
||||||
|
{
|
||||||
|
ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
ValueTask<object?> Send(object message, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IMessage { }
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface INotification : IMessage { }
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface INotificationHandler<in TNotification> where TNotification : INotification
|
||||||
|
{
|
||||||
|
ValueTask Handle(TNotification notification, CancellationToken cancellationToken);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IPipelineBehavior<TMessage, TResponse> where TMessage : notnull, IMessage
|
||||||
|
{
|
||||||
|
ValueTask<TResponse> Handle(
|
||||||
|
TMessage message,
|
||||||
|
CancellationToken cancellationToken,
|
||||||
|
MessageHandlerDelegate<TMessage, TResponse> next
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IQuery<out TResponse> : IMessage { }
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IQueryHandler<in TQuery, TResponse> where TQuery : IQuery<TResponse>
|
||||||
|
{
|
||||||
|
ValueTask<TResponse> Handle(TQuery query, CancellationToken cancellationToken);
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IRequest : IRequest<Unit> { }
|
||||||
|
|
||||||
|
public interface IRequest<out TResponse> : IMessage { }
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IRequestHandler<in TRequest> : IRequestHandler<TRequest, Unit> where TRequest : IRequest<Unit>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IRequestHandler<in TRequest, TResponse> where TRequest : IRequest<TResponse>
|
||||||
|
{
|
||||||
|
ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken);
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Mediator;
|
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public record Initialize : IRequest;
|
public record Initialize : IRequest;
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public class InitializeHandler : IRequestHandler<Initialize>
|
public class InitializeHandler : IRequestHandler<Initialize>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public record class Initialized : IRequest;
|
public record class Initialized : IRequest;
|
||||||
@@ -1,49 +1,17 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public class Mediator : IMediator
|
public class Mediator : IMediator
|
||||||
{
|
{
|
||||||
private readonly IServiceProvider factory;
|
private readonly IServiceFactory factory;
|
||||||
|
|
||||||
public Mediator(IServiceProvider factory)
|
public Mediator(IServiceFactory factory)
|
||||||
{
|
{
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamQuery<TResponse> query, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamRequest<TResponse> request, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamCommand<TResponse> command, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IAsyncEnumerable<object?> CreateStream(object request, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ValueTask Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ValueTask Publish(object notification, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
|
public ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
dynamic? handler = factory.GetService(typeof(RequestClassHandlerWrapper<,>).MakeGenericType(request.GetType(), typeof(TResponse)));
|
dynamic? handler = factory.Create(typeof(RequestClassHandlerWrapper<,>).MakeGenericType(request.GetType(), typeof(TResponse)));
|
||||||
if (handler is not null)
|
if (handler is not null)
|
||||||
{
|
{
|
||||||
return handler.Handle((dynamic)request, cancellationToken);
|
return handler.Handle((dynamic)request, cancellationToken);
|
||||||
@@ -54,7 +22,7 @@ public class Mediator : IMediator
|
|||||||
|
|
||||||
public ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command, CancellationToken cancellationToken = default)
|
public ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
dynamic? handler = factory.GetService(typeof(CommandClassHandlerWrapper<,>).MakeGenericType(command.GetType(), typeof(TResponse)));
|
dynamic? handler = factory.Create(typeof(CommandClassHandlerWrapper<,>).MakeGenericType(command.GetType(), typeof(TResponse)));
|
||||||
if (handler is not null)
|
if (handler is not null)
|
||||||
{
|
{
|
||||||
return handler.Handle((dynamic)command, cancellationToken);
|
return handler.Handle((dynamic)command, cancellationToken);
|
||||||
@@ -65,7 +33,7 @@ public class Mediator : IMediator
|
|||||||
|
|
||||||
public ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query, CancellationToken cancellationToken = default)
|
public ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
dynamic? handler = factory.GetService(typeof(QueryClassHandlerWrapper<,>).MakeGenericType(query.GetType(), typeof(TResponse)));
|
dynamic? handler = factory.Create(typeof(QueryClassHandlerWrapper<,>).MakeGenericType(query.GetType(), typeof(TResponse)));
|
||||||
if (handler is not null)
|
if (handler is not null)
|
||||||
{
|
{
|
||||||
return handler.Handle((dynamic)query, cancellationToken);
|
return handler.Handle((dynamic)query, cancellationToken);
|
||||||
@@ -82,7 +50,7 @@ public class Mediator : IMediator
|
|||||||
{
|
{
|
||||||
Type responseType = arguments[0];
|
Type responseType = arguments[0];
|
||||||
|
|
||||||
dynamic? handler = factory.GetService(typeof(RequestClassHandlerWrapper<,>).MakeGenericType(message.GetType(), responseType));
|
dynamic? handler = factory.Create(typeof(RequestClassHandlerWrapper<,>).MakeGenericType(message.GetType(), responseType));
|
||||||
if (handler is not null)
|
if (handler is not null)
|
||||||
{
|
{
|
||||||
return handler.Handle((dynamic)message, cancellationToken);
|
return handler.Handle((dynamic)message, cancellationToken);
|
||||||
@@ -96,7 +64,7 @@ public class Mediator : IMediator
|
|||||||
{
|
{
|
||||||
Type responseType = arguments[0];
|
Type responseType = arguments[0];
|
||||||
|
|
||||||
dynamic? handler = factory.GetService(typeof(CommandClassHandlerWrapper<,>).MakeGenericType(message.GetType(), responseType));
|
dynamic? handler = factory.Create(typeof(CommandClassHandlerWrapper<,>).MakeGenericType(message.GetType(), responseType));
|
||||||
if (handler is not null)
|
if (handler is not null)
|
||||||
{
|
{
|
||||||
return handler.Handle((dynamic)message, cancellationToken);
|
return handler.Handle((dynamic)message, cancellationToken);
|
||||||
@@ -110,7 +78,7 @@ public class Mediator : IMediator
|
|||||||
{
|
{
|
||||||
Type responseType = arguments[0];
|
Type responseType = arguments[0];
|
||||||
|
|
||||||
dynamic? handler = factory.GetService(typeof(QueryClassHandlerWrapper<,>).MakeGenericType(message.GetType(), responseType));
|
dynamic? handler = factory.Create(typeof(QueryClassHandlerWrapper<,>).MakeGenericType(message.GetType(), responseType));
|
||||||
if (handler is not null)
|
if (handler is not null)
|
||||||
{
|
{
|
||||||
return handler.Handle((dynamic)message, cancellationToken);
|
return handler.Handle((dynamic)message, cancellationToken);
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public delegate ValueTask<TResponse> MessageHandlerDelegate<TMessage, TResponse>(TMessage message, CancellationToken cancellationToken) where TMessage : notnull, IMessage;
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public class QueryClassHandlerWrapper<TRequest, TResponse> where TRequest : class, IQuery<TResponse>
|
public class QueryClassHandlerWrapper<TRequest, TResponse> where TRequest : class, IQuery<TResponse>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public class RequestClassHandlerWrapper<TRequest, TResponse> where TRequest : class, IRequest<TResponse>
|
public class RequestClassHandlerWrapper<TRequest, TResponse> where TRequest : class, IRequest<TResponse>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public readonly struct Unit : IEquatable<Unit>, IComparable<Unit>, IComparable
|
||||||
|
{
|
||||||
|
private static readonly Unit _value = new();
|
||||||
|
|
||||||
|
public static ref readonly Unit Value => ref _value;
|
||||||
|
|
||||||
|
public static ValueTask<Unit> ValueTask => new ValueTask<Unit>(_value);
|
||||||
|
|
||||||
|
public int CompareTo(Unit other) => 0;
|
||||||
|
|
||||||
|
int IComparable.CompareTo(object? obj) => 0;
|
||||||
|
|
||||||
|
public override int GetHashCode() => 0;
|
||||||
|
|
||||||
|
public bool Equals(Unit other) => true;
|
||||||
|
|
||||||
|
public override bool Equals(object? obj) => obj is Unit;
|
||||||
|
|
||||||
|
public static bool operator ==(Unit _, Unit __) => true;
|
||||||
|
|
||||||
|
public static bool operator !=(Unit _, Unit __) => false;
|
||||||
|
|
||||||
|
public override string ToString() => "()";
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Mediator;
|
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public record Navigate : IRequest
|
public record Navigate : IRequest
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public record NavigateBack(object Route) : IRequest;
|
public record NavigateBack(object Route) : IRequest;
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public record NavigationRoute(string Name, object Route) : IRequest;
|
public record NavigationRoute(string Name, object Route) : IRequest;
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public record Create(Type Type, params object?[] Parameters) : IRequest<object?>;
|
public record Create(Type Type, params object?[] Parameters) : IRequest<object?>;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public class ServiceCreator<I, T> : IServiceCreator<I>
|
public class ServiceCreator<I, T> : IServiceCreator<I>
|
||||||
{
|
{
|
||||||
public virtual object Create(Func<Type, object[], object> creator, params object[] parameters)
|
public object Create(Func<Type, object[], object> creator, params object[] parameters)
|
||||||
{
|
{
|
||||||
return creator(typeof(T), parameters);
|
return creator(typeof(T), parameters);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Mediator;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Framework.Foundation;
|
|
||||||
|
|
||||||
public class ServiceFactoryHandler : IRequestHandler<Create, object?>
|
public class ServiceFactoryHandler : IRequestHandler<Create, object?>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user