45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using GerstITS.Data.EntityFramework;
|
|
using GerstITS.Examples.JobDashboard.Configurations;
|
|
using GerstITS.Examples.JobDashboard.Data;
|
|
using GerstITS.Examples.JobDashboard.Jobs;
|
|
using GerstITS.IoC;
|
|
using GerstITS.Job.Scheduling;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace GerstITS.Examples.JobDashboard;
|
|
|
|
public sealed class Module : IIoCModule<IServiceCollection>
|
|
{
|
|
#region IIoCModule
|
|
|
|
public void RegisterComponents(IServiceCollection container)
|
|
{
|
|
RegisterInMemoryStore(container);
|
|
RegisterJobs(container);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
private static void RegisterInMemoryStore(IServiceCollection container)
|
|
{
|
|
// The InMemory provider has no migrations, so disable the framework's auto-migration startup task.
|
|
container.AddSingleton<IEntityFrameworkMigrationConfiguration, NoDatabaseMigrationConfiguration>();
|
|
|
|
// Wire the EF Core InMemory provider through the framework's session (unit of work). No real database.
|
|
container.AddScoped<IDatabaseConfigurator, InMemoryDatabaseConfigurator>();
|
|
container.AddTransient(_ => new DbContextOptionsBuilder<JobRunDbContext>().Options);
|
|
container.AddScoped<JobRunDbContext>();
|
|
container.AddEntityFrameworkSession<JobRunDbContext>();
|
|
}
|
|
|
|
private static void RegisterJobs(IServiceCollection container)
|
|
{
|
|
container.RegisterJob<ReportGenerationJob, ReportGenerationJobConfiguration>(IgnoreConditions.EntityFramework, IgnoreConditions.Swagger);
|
|
}
|
|
|
|
#endregion
|
|
}
|