I have a command / handler based architecture app . I have the following interface:
public interface ICommandHandler<TCommand>
{
void Handle(TCommand command);
}
There are many non-general implementations of this interface. These implementations are wrapped by common decorators, such as:
public class ProfilingCommandHandlerDecorator<TCommand> : ICommandHandler<TCommand>
{
private readonly ICommandHandler<TCommand> decoratee;
public ProfilingCommandHandlerDecorator(ICommandHandler<TCommand> decoratee)
{
this.decoratee = decoratee;
}
public void Handle(TCommand command)
{
this.decoratee.Handle(command);
}
}
However, some of these expanders should be applied conditionally based on the flag in the configuration file. I found this answer , which conditionally refers to the use of non-standard decorators; not about the general decorator. How can we achieve this with common decorators in Autofac?
source
share