fengling-platform/Fengling.Platform.Infrastructure/Extensions.cs
movingsam a6558137af feat(03-gateway-infrastructure-update): update Infrastructure layer for GwCluster
- Updated PlatformDbContext: removed GwTenant/GwServiceInstance DbSets, added GwCluster with EF Core config
- Created IClusterStore interface with CRUD and Destination management methods
- Created ClusterStore<TContext> implementation with soft delete and embedded Destinations support
- Deleted obsolete IInstanceStore and InstanceStore (replaced by IClusterStore)
- Updated Extensions.cs and GatewayExtensions.cs to register IClusterStore

Plan 03 of Phase 03 complete.
2026-03-03 15:46:57 +08:00

36 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<IClusterStore, ClusterStore<TContext>>();
services.AddScoped<IRouteManager, RouteManager>();
serviceAction?.Invoke(services);
return services;
}
}