Adds Decorator, wip
This commit is contained in:
parent
a86a2d7ade
commit
49f9b99ee1
9 changed files with 112 additions and 45 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using Autofac;
|
||||
using PlanTempus.Components.Users.Create;
|
||||
using PlanTempus.Core.SeqLogging;
|
||||
|
||||
namespace PlanTempus.Components.ModuleRegistry
|
||||
|
|
@ -9,15 +10,34 @@ namespace PlanTempus.Components.ModuleRegistry
|
|||
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
// Registrer alle handlers
|
||||
builder.RegisterAssemblyTypes()
|
||||
.AsClosedTypesOf(typeof(ICommandHandler<>))
|
||||
.InstancePerLifetimeScope();
|
||||
|
||||
// Registrer en decorator for alle ICommandHandler<TCommand>
|
||||
builder.RegisterGenericDecorator(
|
||||
typeof(CreateUserHandlerDecorator<>), // Din decorator-klasse
|
||||
typeof(ICommandHandler<>)); // Interface, der skal dekoreres
|
||||
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<,>));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue