Skip to content

Commit 1a32b4b

Browse files
AlexGreatDevAlexGreatDev
authored andcommitted
Add EventFlowMongoInitializer for MongoDB setup
Introduces the `EventFlowMongoInitializer` class in the `EventFlow.MongoDB.EventStore` namespace. This class facilitates the initialization of MongoDB event persistence by utilizing an `IServiceProvider` to manage dependencies and service lifetimes. The `Initialize` method creates a scope and retrieves an instance of `IMongoDbEventPersistenceInitializer` to perform the necessary setup.
1 parent 5c2379f commit 1a32b4b

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace EventFlow.MongoDB.EventStore
7+
{
8+
public class EventFlowMongoInitializer
9+
{
10+
private readonly IServiceProvider _serviceProvider;
11+
12+
public EventFlowMongoInitializer(IServiceProvider serviceProvider)
13+
{
14+
_serviceProvider = serviceProvider;
15+
}
16+
17+
public void Initialize()
18+
{
19+
using var scope = _serviceProvider.CreateScope();
20+
var initializer = scope.ServiceProvider.GetRequiredService<IMongoDbEventPersistenceInitializer>();
21+
initializer.Initialize();
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)