-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJobbaEfBuilder.cs
37 lines (30 loc) · 1.34 KB
/
JobbaEfBuilder.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
using Jobba.Core.Builders;
using Jobba.Core.Interfaces.Repositories;
using Jobba.Store.EF.Implementations;
using Jobba.Store.EF.Interfaces;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Jobba.Store.EF.Builders;
public class JobbaEfBuilder
{
public JobbaBuilder Builder { get; }
public JobbaEfBuilder(JobbaBuilder jobbaBuilder)
{
Builder = jobbaBuilder;
RegisterJobbaRequiredStores(jobbaBuilder);
}
public JobbaEfBuilder WithDbInitializer() => WithDbInitializer<DefaultJobbaDbInitializer>();
public JobbaEfBuilder WithDbInitializer<T>() where T : class, IJobbaDbInitializer
{
Builder.Services.TryAddSingleton<IJobbaDbInitializer, T>();
return this;
}
private static void RegisterJobbaRequiredStores(JobbaBuilder jobbaBuilder)
{
jobbaBuilder.Services.TryAddTransient<IJobListStore, JobbaEfJobListStore>();
jobbaBuilder.Services.TryAddTransient<IJobProgressStore, JobbaEfJobProgressStore>();
jobbaBuilder.Services.TryAddTransient<IJobStore, JobbaEfJobStore>();
jobbaBuilder.Services.TryAddTransient<IJobCleanUpStore, JobbaEfCleanUpStore>();
jobbaBuilder.Services.TryAddTransient<IJobRegistrationStore, JobbaEfJobRegistrationStore>();
jobbaBuilder.Services.TryAddTransient<IDbContextProvider, DefaultDbContextProvider>();
}
}