28 lines
889 B
C#
28 lines
889 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Fengling.Platform.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// Gateway 服务扩展方法
|
|
/// </summary>
|
|
public static class GatewayExtensions
|
|
{
|
|
/// <summary>
|
|
/// 注册 Gateway 核心服务
|
|
/// </summary>
|
|
/// <typeparam name="TContext">数据库上下文类型</typeparam>
|
|
/// <param name="services">服务集合</param>
|
|
/// <returns>服务集合</returns>
|
|
public static IServiceCollection AddGatewayCore<TContext>(this IServiceCollection services)
|
|
where TContext : PlatformDbContext
|
|
{
|
|
// 注册 Gateway stores
|
|
services.AddScoped<IRouteStore, RouteStore<TContext>>();
|
|
services.AddScoped<IInstanceStore, InstanceStore<TContext>>();
|
|
|
|
// 注册 Gateway managers
|
|
services.AddScoped<IRouteManager, RouteManager>();
|
|
|
|
return services;
|
|
}
|
|
} |