- 新增 GatewayAggregate 领域实体 (GwTenant, GwTenantRoute, GwServiceInstance) - 新增 IRouteStore, RouteStore, IInstanceStore, InstanceStore - 新增 IRouteManager, RouteManager - 合并 GatewayDbContext 到 PlatformDbContext - 统一 Extensions.AddPlatformCore 注册所有服务
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Fengling.Platform.Infrastructure;
|
|
|
|
public static class Extensions
|
|
{
|
|
public static IServiceCollection AddPlatformCore<TContext>(this IServiceCollection services,
|
|
Action<DbContextOptionsBuilder>? optionsAction = null,
|
|
Action<IServiceCollection>? serviceAction = null
|
|
)
|
|
where TContext : PlatformDbContext
|
|
{
|
|
if (optionsAction != null)
|
|
{
|
|
var isRegistry = services.Any(x => x.ImplementationType == typeof(TContext));
|
|
if (!isRegistry)
|
|
{
|
|
services.AddDbContext<TContext>(optionsAction);
|
|
}
|
|
}
|
|
|
|
// Platform 服务
|
|
services.AddScoped<ITenantStore, TenantStore<TContext>>();
|
|
services.AddScoped<ITenantManager, TenantManager>();
|
|
|
|
// Gateway 服务
|
|
services.AddScoped<IRouteStore, RouteStore<TContext>>();
|
|
services.AddScoped<IInstanceStore, InstanceStore<TContext>>();
|
|
services.AddScoped<IRouteManager, RouteManager>();
|
|
|
|
serviceAction?.Invoke(services);
|
|
|
|
return services;
|
|
}
|
|
} |