refactor mapping again
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace Hyperbar.Windows.Primary;
|
namespace Hyperbar.Windows.Primary;
|
||||||
|
|
||||||
public class WidgetComponentMappingHandler(PrimaryWidgetConfiguration configuration,
|
public class WidgetComponentMappingHandler(PrimaryWidgetConfiguration configuration,
|
||||||
@@ -6,7 +7,7 @@ public class WidgetComponentMappingHandler(PrimaryWidgetConfiguration configurat
|
|||||||
IMediator mediator) :
|
IMediator mediator) :
|
||||||
IMappingHandler<PrimaryWidgetConfiguration, IEnumerable<IWidgetComponentViewModel>>
|
IMappingHandler<PrimaryWidgetConfiguration, IEnumerable<IWidgetComponentViewModel>>
|
||||||
{
|
{
|
||||||
public IEnumerable<IWidgetComponentViewModel> Handle()
|
public IEnumerable<IWidgetComponentViewModel> Map()
|
||||||
{
|
{
|
||||||
foreach (IPrimaryCommandConfiguration item in configuration)
|
foreach (IPrimaryCommandConfiguration item in configuration)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,11 +50,10 @@ public static class IServiceCollectionExtensions
|
|||||||
{
|
{
|
||||||
if (mappingContract.GetGenericArguments() is { Length: 2 } arguments)
|
if (mappingContract.GetGenericArguments() is { Length: 2 } arguments)
|
||||||
{
|
{
|
||||||
Type requestType = arguments[0];
|
|
||||||
Type responseType = arguments[1];
|
Type responseType = arguments[1];
|
||||||
|
|
||||||
services.AddTransient(typeof(THandler));
|
services.AddTransient(typeof(THandler));
|
||||||
services.AddTransient(responseType, provider => ((dynamic)provider.GetRequiredService<THandler>()).Handle());
|
services.AddTransient(responseType, provider => ((dynamic)provider.GetRequiredService<THandler>()).Map());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar;
|
||||||
|
|
||||||
public interface IMappingHandler<TFrom, TTo> :
|
public interface IMappingHandler<TFrom, TTo> : IHandler
|
||||||
IHandler
|
|
||||||
{
|
{
|
||||||
TTo Handle();
|
TTo Map();
|
||||||
}
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
namespace Hyperbar;
|
|
||||||
|
|
||||||
public class Map<TFrom, TTo>;
|
|
||||||
Reference in New Issue
Block a user