33 lines
932 B
C#
33 lines
932 B
C#
|
|
using Microsoft.AspNetCore.Routing;
|
||
|
|
using Microsoft.Extensions.Configuration;
|
||
|
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
|
|
||
|
|
namespace TeamUp.Bootstrap;
|
||
|
|
|
||
|
|
public static class TeamUpModuleExtensions
|
||
|
|
{
|
||
|
|
/// <summary>Runs every module's <c>Register</c>. Called by BOTH hosts.</summary>
|
||
|
|
public static IServiceCollection AddTeamUpModules(
|
||
|
|
this IServiceCollection services,
|
||
|
|
IConfiguration configuration)
|
||
|
|
{
|
||
|
|
foreach (var module in ModuleCatalog.All)
|
||
|
|
{
|
||
|
|
module.Register(services, configuration);
|
||
|
|
}
|
||
|
|
|
||
|
|
return services;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>Runs every module's <c>MapEndpoints</c>. Called by the WEB host only.</summary>
|
||
|
|
public static IEndpointRouteBuilder MapTeamUpModules(this IEndpointRouteBuilder endpoints)
|
||
|
|
{
|
||
|
|
foreach (var module in ModuleCatalog.All)
|
||
|
|
{
|
||
|
|
module.MapEndpoints(endpoints);
|
||
|
|
}
|
||
|
|
|
||
|
|
return endpoints;
|
||
|
|
}
|
||
|
|
}
|