PlanTempusApp/PlanTempus.Components/ModuleRegistry/CommandModule.cs

44 lines
No EOL
1.5 KiB
C#

using Autofac;
using PlanTempus.Components.Users.Create;
using PlanTempus.Core.SeqLogging;
namespace PlanTempus.Components.ModuleRegistry
{
public class CommandModule : Module
{
// public required SeqConfiguration SeqConfiguration { get; set; }
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<PlanTempus.Components.CommandHandler>()
.As<PlanTempus.Components.ICommandHandler>()
.InstancePerLifetimeScope();
builder.RegisterAssemblyTypes(ThisAssembly)
.Where(t => !typeof(ICommandHandlerDecorator).IsAssignableFrom(t))
.AsClosedTypesOf(typeof(ICommandHandler<,>))
.InstancePerLifetimeScope();
// Registrer alle handlers
// builder.RegisterAssemblyTypes(ThisAssembly)
// .AsClosedTypesOf(typeof(ICommandHandler<,>))
// .InstancePerLifetimeScope();
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<,>));
}
}
}