Changed the module injection pattern
This commit is contained in:
@@ -4,13 +4,13 @@ namespace Hutopy.Web.Features.Contents;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddContentModule(
|
||||
this IServiceCollection services,
|
||||
public static WebApplicationBuilder AddContentModule(
|
||||
this WebApplicationBuilder builder,
|
||||
Action<DbContextOptionsBuilder>? configureAction = null)
|
||||
{
|
||||
services.AddDbContext<ContentDbContext>(configureAction);
|
||||
services.AddScoped<ContentDbContextInitializer>();
|
||||
builder.Services.AddDbContext<ContentDbContext>(configureAction);
|
||||
builder.Services.AddScoped<ContentDbContextInitializer>();
|
||||
|
||||
return services;
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace Hutopy.Web.Features.Messages;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddMessagingModule(
|
||||
this IServiceCollection services,
|
||||
public static WebApplicationBuilder AddMessagingModule(
|
||||
this WebApplicationBuilder builder,
|
||||
Action<DbContextOptionsBuilder>? configureAction = null)
|
||||
{
|
||||
services.AddDbContext<MessagingDbContext>(configureAction);
|
||||
services.AddScoped<MessagingDbContextInitializer>();
|
||||
builder.Services.AddDbContext<MessagingDbContext>(configureAction);
|
||||
builder.Services.AddScoped<MessagingDbContextInitializer>();
|
||||
|
||||
return services;
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,22 +7,22 @@ namespace Hutopy.Web.Features.Users;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddUsersModule(
|
||||
this IServiceCollection services,
|
||||
public static WebApplicationBuilder AddIdentityModule(
|
||||
this WebApplicationBuilder builder,
|
||||
Action<DbContextOptionsBuilder>? configureAction = null)
|
||||
{
|
||||
services.AddDbContext<MessagingDbContext>(configureAction);
|
||||
services.AddScoped<MessagingDbContextInitializer>();
|
||||
builder.Services.AddDbContext<MessagingDbContext>(configureAction);
|
||||
builder.Services.AddScoped<MessagingDbContextInitializer>();
|
||||
|
||||
services.AddDbContext<IdentityDbContext>(configureAction);
|
||||
services.AddScoped<IdentityDbContextInitializer>();
|
||||
builder.Services.AddDbContext<IdentityDbContext>(configureAction);
|
||||
builder.Services.AddScoped<IdentityDbContextInitializer>();
|
||||
|
||||
services.AddAuthentication()
|
||||
builder.Services.AddAuthentication()
|
||||
.AddBearerToken(IdentityConstants.BearerScheme);
|
||||
|
||||
services.AddAuthorizationBuilder();
|
||||
builder.Services.AddAuthorizationBuilder();
|
||||
|
||||
services
|
||||
builder.Services
|
||||
.AddIdentityCore<IdentityUser>()
|
||||
.AddUserManager<IdentityUserManager>()
|
||||
.AddRoles<IdentityRole>()
|
||||
@@ -32,12 +32,12 @@ public static class DependencyInjection
|
||||
.AddDefaultTokenProviders();
|
||||
|
||||
// Singleton services
|
||||
services.AddSingleton(TimeProvider.System);
|
||||
services.AddSingleton<AzureBlobStorage>();
|
||||
builder.Services.AddSingleton(TimeProvider.System);
|
||||
builder.Services.AddSingleton<AzureBlobStorage>();
|
||||
|
||||
// Scoped services
|
||||
services.AddScoped<IdentityService>();
|
||||
builder.Services.AddScoped<IdentityService>();
|
||||
|
||||
return services;
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user