zeroframework/Services/Identity/ZeroFramework.IdentityServer.API/Tenants/TenantMiddlewareExtensions.cs
2023-12-05 17:22:48 +08:00

20 lines
700 B
C#

namespace ZeroFramework.IdentityServer.API.Tenants
{
public static class TenantMiddlewareExtensions
{
public static IServiceCollection AddTenantMiddleware(this IServiceCollection services)
{
services.AddSingleton<ICurrentTenantAccessor, CurrentTenantAccessor>();
services.AddTransient<ICurrentTenant, CurrentTenant>();
services.AddTransient<ITenantProvider, TenantProvider>();
return services.AddTransient<TenantMiddleware>();
}
public static IApplicationBuilder UseTenantMiddleware(this IApplicationBuilder builder)
{
return builder.UseMiddleware<TenantMiddleware>();
}
}
}