PlanTempusApp/PlanTempus.Components/ModuleRegistry/CommandModule.cs

37 lines
1.3 KiB
C#
Raw Permalink Normal View History

2025-03-10 15:56:22 +01:00
using Autofac;
using PlanTempus.Components.Accounts.Create;
2025-03-12 00:13:53 +01:00
using PlanTempus.Core.CommandQueries;
2025-03-10 15:56:22 +01:00
using PlanTempus.Core.SeqLogging;
namespace PlanTempus.Components.ModuleRegistry
{
public class CommandModule : Module
{
// public required SeqConfiguration SeqConfiguration { get; set; }
protected override void Load(ContainerBuilder builder)
{
2025-03-11 00:28:06 +01:00
builder.RegisterType<PlanTempus.Components.CommandHandler>()
.As<PlanTempus.Components.ICommandHandler>()
2025-03-10 15:56:22 +01:00
.InstancePerLifetimeScope();
2025-03-12 00:13:53 +01:00
2025-03-11 00:28:06 +01:00
builder.RegisterAssemblyTypes(ThisAssembly)
.Where(t => !typeof(ICommandHandlerDecorator).IsAssignableFrom(t))
2025-03-12 00:13:53 +01:00
.AsClosedTypesOf(typeof(ICommandHandler<>))
2025-03-11 00:28:06 +01:00
.InstancePerLifetimeScope();
2025-03-10 15:56:22 +01:00
2025-03-11 00:28:06 +01:00
builder.RegisterAssemblyTypes(ThisAssembly)
2025-03-12 00:13:53 +01:00
.As<ICommandHandlerDecorator>();
builder.RegisterGenericDecorator(
typeof(CommandHandlerDecorator<>),
typeof(ICommandHandler<>));
2025-03-11 00:28:06 +01:00
//
// Registrer en decorator for alle ICommandHandler<TCommand>
// builder.RegisterGenericDecorator(
// typeof(CommandHandlerDecorator<,>),
// typeof(ICommandHandler<,>));
2025-03-10 15:56:22 +01:00
}
}
}