- 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.
36 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|