-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSoftawareCqsDecoratorBuilder.cs
More file actions
31 lines (27 loc) · 1.09 KB
/
SoftawareCqsDecoratorBuilder.cs
File metadata and controls
31 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using SimpleInjector;
namespace softaware.Cqs;
/// <summary>
/// Provides methods for configuring decorators for the softaware CQS infrastructure.
/// </summary>
public class SoftawareCqsDecoratorBuilder
{
/// <summary>
/// The SimpleInjector container.
/// </summary>
public Container Container { get; }
/// <summary>
/// Initializes a new instance of the <see cref="SoftawareCqsDecoratorBuilder"/> class.
/// </summary>
/// <param name="container">The SimpleInjector container.</param>
public SoftawareCqsDecoratorBuilder(Container container)
=> this.Container = container ?? throw new ArgumentNullException(nameof(container));
/// <summary>
/// Adds a request handler decorator.
/// </summary>
/// <param name="decoratorType">Type type of the decorator. The decorator must implement <see cref="IRequestHandler{TRequest, TResult}"/>.</param>
public SoftawareCqsDecoratorBuilder AddRequestHandlerDecorator(Type decoratorType)
{
this.Container.RegisterDecorator(typeof(IRequestHandler<,>), decoratorType);
return this;
}
}