From 674a61f122b4b8d178a724394b1c8c5dbf04f507 Mon Sep 17 00:00:00 2001 From: staneee Date: Fri, 4 Dec 2020 16:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=9A=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Riven.Domain/RivenDomainExtensions.cs | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Riven.Domain/RivenDomainExtensions.cs diff --git a/src/Riven.Domain/RivenDomainExtensions.cs b/src/Riven.Domain/RivenDomainExtensions.cs new file mode 100644 index 0000000..50509dd --- /dev/null +++ b/src/Riven.Domain/RivenDomainExtensions.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; + +using Riven.MultiTenancy; + +namespace Riven +{ + public static class RivenDomainExtensions + { + /// + /// 添加Riven的多租户配置 + /// + /// + /// + /// + public static IServiceCollection AddRivenMultiTenancyOptions(this IServiceCollection services, Action optionConfiguration = null) + { + var multiTenancyOptions = new DefaultMultiTenancyOptions(); + optionConfiguration?.Invoke(multiTenancyOptions); + services.TryAddSingleton(multiTenancyOptions); + + + return services; + } + + /// + /// 添加多租户提供者 + /// + /// + /// + public static IServiceCollection AddRivenMultiTenancyProvider(this IServiceCollection services) + where TProvider : class, IMultiTenancyProvider + { + services.TryAddScoped(); + + return services; + } + } +}