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