Skip to content

Commit

Permalink
增加多租户配置
Browse files Browse the repository at this point in the history
  • Loading branch information
yihango committed Dec 4, 2020
1 parent 20382d2 commit 674a61f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Riven.Domain/RivenDomainExtensions.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 添加Riven的多租户配置
/// </summary>
/// <param name="services"></param>
/// <param name="optionConfiguration"></param>
/// <returns></returns>
public static IServiceCollection AddRivenMultiTenancyOptions(this IServiceCollection services, Action<IMultiTenancyOptions> optionConfiguration = null)
{
var multiTenancyOptions = new DefaultMultiTenancyOptions();
optionConfiguration?.Invoke(multiTenancyOptions);
services.TryAddSingleton<IMultiTenancyOptions>(multiTenancyOptions);


return services;
}

/// <summary>
/// 添加多租户提供者
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddRivenMultiTenancyProvider<TProvider>(this IServiceCollection services)
where TProvider : class, IMultiTenancyProvider
{
services.TryAddScoped<IMultiTenancyProvider, TProvider>();

return services;
}
}
}

0 comments on commit 674a61f

Please sign in to comment.