hello-shop/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/MultiTenancyExtensions.cs
2024-04-28 16:00:15 +08:00

24 lines
688 B
C#

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace MultiTenancySample.ServiceDefaults
{
public static class MultiTenancyExtensions
{
public static IServiceCollection AddMultiTenancy(this IServiceCollection services)
{
services.AddScoped<ICurrentTenant, CurrentTenant>();
services.AddScoped<ITenantIdProvider, TenantIdProvider>();
return services.AddScoped<TenantMiddleware>();
}
public static IApplicationBuilder UseMultiTenancy(this IApplicationBuilder app)
{
app.UseMiddleware<TenantMiddleware>();
return app;
}
}
}