refactor mapping again

This commit is contained in:
TheXamlGuy
2024-01-07 19:04:24 +00:00
parent 2e8af23784
commit bc29fbc805
4 changed files with 6 additions and 10 deletions
@@ -1,4 +1,5 @@
namespace Hyperbar.Windows.Primary;
public class WidgetComponentMappingHandler(PrimaryWidgetConfiguration configuration,
@@ -6,7 +7,7 @@ public class WidgetComponentMappingHandler(PrimaryWidgetConfiguration configurat
IMediator mediator) :
IMappingHandler<PrimaryWidgetConfiguration, IEnumerable<IWidgetComponentViewModel>>
{
public IEnumerable<IWidgetComponentViewModel> Handle()
public IEnumerable<IWidgetComponentViewModel> Map()
{
foreach (IPrimaryCommandConfiguration item in configuration)
{
@@ -50,11 +50,10 @@ public static class IServiceCollectionExtensions
{
if (mappingContract.GetGenericArguments() is { Length: 2 } arguments)
{
Type requestType = arguments[0];
Type responseType = arguments[1];
services.AddTransient(typeof(THandler));
services.AddTransient(responseType, provider => ((dynamic)provider.GetRequiredService<THandler>()).Handle());
services.AddTransient(responseType, provider => ((dynamic)provider.GetRequiredService<THandler>()).Map());
}
}
+2 -3
View File
@@ -1,7 +1,6 @@
namespace Hyperbar;
public interface IMappingHandler<TFrom, TTo> :
IHandler
public interface IMappingHandler<TFrom, TTo> : IHandler
{
TTo Handle();
TTo Map();
}
-3
View File
@@ -1,3 +0,0 @@
namespace Hyperbar;
public class Map<TFrom, TTo>;