PlanTempusApp/PlanTempus.Components/ModuleRegistry/CommandModule.cs

44 lines
1.5 KiB
C#
Raw Normal View History

2025-03-10 15:56:22 +01:00
using Autofac;
2025-03-11 00:28:06 +01:00
using PlanTempus.Components.Users.Create;
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-11 00:28:06 +01:00
builder.RegisterAssemblyTypes(ThisAssembly)
.Where(t => !typeof(ICommandHandlerDecorator).IsAssignableFrom(t))
.AsClosedTypesOf(typeof(ICommandHandler<,>))
.InstancePerLifetimeScope();
// Registrer alle handlers
// builder.RegisterAssemblyTypes(ThisAssembly)
// .AsClosedTypesOf(typeof(ICommandHandler<,>))
// .InstancePerLifetimeScope();
2025-03-10 15:56:22 +01:00
2025-03-11 00:28:06 +01:00
builder.RegisterAssemblyTypes(ThisAssembly)
.As<ICommandHandlerDecorator>();
builder.RegisterDecorator(
typeof(CreateUserHandlerDecorator),
typeof(ICommandHandler<CreateUserCommand, CreateUserResult>));
//
// Registrer en decorator for alle ICommandHandler<TCommand>
// builder.RegisterGenericDecorator(
// typeof(CommandHandlerDecorator<,>),
// typeof(ICommandHandler<,>));
2025-03-10 15:56:22 +01:00
}
}
}