-
Notifications
You must be signed in to change notification settings - Fork 2
/
CQRSBooter.cs
49 lines (42 loc) · 1.67 KB
/
CQRSBooter.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using AspNetCoreSample.Domain;
using BE.CQRS.Data.MongoDb;
using BE.CQRS.Di.AspCore;
using BE.CQRS.Domain.Configuration;
using BE.CQRS.Domain.Denormalization;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using MongoDB.Driver;
namespace AspNetCoreSample
{
public static class CQRSBooter
{
public static IServiceCollection AddEventSource(this IServiceCollection services)
{
var cfg = new EventSourceConfiguration()
.SetEventSecret("232") //Your secret key which is used to sign the vents
.SetDomainObjectAssemblies(typeof(Customer).Assembly); //Tell the place where your domainobjects are
services
.AddServiceProviderDomainObjectAcitvator()
.AddMongoDomainObjectRepository(() =>
new MongoClient("mongodb://localhost:27017/?connectTimeoutMS=10000")
.GetDatabase("eventTests2"))
.AddConventionBasedInMemoryCommandBus(cfg)
.AddEventSource(cfg);
return services;
}
public static IServiceCollection AddDenormalizer(this IServiceCollection services)
{
DenormalizerConfiguration config = new DenormalizerConfiguration()
.SetDenormalizerAssemblies(typeof(Customer).Assembly);
services
.AddServiceProviderDenormalizerActivator()
.AddImmediateDenormalization()
.AddDenormalization(config)
.AddProjectionBuilder();
return services;
}
}
}