-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSoftawareCqsExtensions.cs
More file actions
30 lines (25 loc) · 1.24 KB
/
SoftawareCqsExtensions.cs
File metadata and controls
30 lines (25 loc) · 1.24 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
using SimpleInjector;
using softaware.Cqs.SimpleInjector;
namespace softaware.Cqs;
/// <summary>
/// Provides extension methods for the SimpleInjector container to configure the softaware CQS infrastructure.
/// </summary>
public static class SoftawareCqsExtensions
{
/// <summary>
/// Adds the softaware CQS infrastructure and registers all required instances in the SimpleInjector container.
/// </summary>
/// <param name="container">The SimpleInjector container.</param>
/// <param name="softawareCqsTypesBuilderAction">The types builder for registering assemblies from where to find <see cref="IRequestHandler{TRequest, TResult}"/> instances.</param>
/// <returns>The softaware CQS builder.</returns>
public static SoftawareCqsBuilder AddSoftawareCqs(
this Container container,
Action<SoftawareCqsTypesBuilder> softawareCqsTypesBuilderAction)
{
container.RegisterInstance<IRequestProcessor>(new DynamicRequestProcessor(container));
var typesBuilder = new SoftawareCqsTypesBuilder();
softawareCqsTypesBuilderAction.Invoke(typesBuilder);
container.Register(typeof(IRequestHandler<,>), typesBuilder.RegisteredAssemblies);
return new SoftawareCqsBuilder(container);
}
}