mirror of https://github.com/abpframework/abp.git
3 changed files with 59 additions and 23 deletions
@ -1,7 +1,7 @@ |
|||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
using Volo.Abp.MultiTenancy; |
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Components.WebAssembly |
namespace Volo.Abp.AspNetCore.Components.WebAssembly.MultiTenancy |
||||
{ |
{ |
||||
[Dependency(ReplaceServices = true)] |
[Dependency(ReplaceServices = true)] |
||||
public class WebAssemblyCurrentTenantAccessor : ICurrentTenantAccessor, ISingletonDependency |
public class WebAssemblyCurrentTenantAccessor : ICurrentTenantAccessor, ISingletonDependency |
||||
@ -0,0 +1,35 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly.MultiTenancy |
||||
|
{ |
||||
|
public class WebAssemblyRemoteTenantStoreCache : IScopedDependency |
||||
|
{ |
||||
|
protected readonly List<TenantConfiguration> CachedTenants = new List<TenantConfiguration>(); |
||||
|
|
||||
|
public virtual TenantConfiguration Find(string name) |
||||
|
{ |
||||
|
return CachedTenants.FirstOrDefault(t => t.Name == name); |
||||
|
} |
||||
|
|
||||
|
public virtual TenantConfiguration Find(Guid id) |
||||
|
{ |
||||
|
return CachedTenants.FirstOrDefault(t => t.Id == id); |
||||
|
} |
||||
|
|
||||
|
public virtual void Set(TenantConfiguration tenant) |
||||
|
{ |
||||
|
var existingTenant = Find(tenant.Id); |
||||
|
if (existingTenant != null) |
||||
|
{ |
||||
|
existingTenant.Name = tenant.Name; |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
CachedTenants.Add(tenant); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue