mirror of https://github.com/abpframework/abp.git
2 changed files with 44 additions and 0 deletions
@ -0,0 +1,27 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
|
|||
namespace Volo.Abp.MultiTenancy; |
|||
|
|||
public class ConfigurationTenantResolveContributor : TenantResolveContributorBase |
|||
{ |
|||
public const string ContributorName = "Configuration"; |
|||
public override string Name => ContributorName; |
|||
|
|||
public override async Task ResolveAsync(ITenantResolveContext context) |
|||
{ |
|||
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|||
var tenantIdOrName = configuration["MultiTenancy:Tenant"]; |
|||
|
|||
if (!tenantIdOrName.IsNullOrEmpty()) |
|||
{ |
|||
context.TenantIdOrName = tenantIdOrName; |
|||
} |
|||
|
|||
await Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Volo.Abp.MultiTenancy; |
|||
|
|||
public static class ConfigurationTenantResolveOptionsExtensions |
|||
{ |
|||
public static void AddConfigurationTenantResolver( |
|||
this AbpTenantResolveOptions options) |
|||
{ |
|||
options.TenantResolvers.InsertAfter( |
|||
r => r is CurrentUserTenantResolveContributor, |
|||
new ConfigurationTenantResolveContributor() |
|||
); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue