TenantContext, LocalTelegramGateway, DefaultPasswordHasher и WTelegramSessionClient переведены на явные реализации; типы в тестах приведены к ITenantContext.
20 lines
578 B
C#
20 lines
578 B
C#
using Deal.SharedKernel.Tenants.Abstractions;
|
|
using Deal.SharedKernel.Tenants.Models;
|
|
|
|
namespace Deal.Infrastructure.Data;
|
|
|
|
public sealed class TenantContext : ITenantContext
|
|
{
|
|
private static readonly AsyncLocal<TenantId?> Current = new();
|
|
|
|
TenantId? ITenantContext.TenantId => Current.Value;
|
|
|
|
bool ITenantContext.HasTenant => Current.Value is not null;
|
|
|
|
string? ITenantContext.SchemaName => Current.Value?.SchemaName;
|
|
|
|
void ITenantContext.SetTenant(TenantId tenantId) => Current.Value = tenantId;
|
|
|
|
void ITenantContext.Reset() => Current.Value = null;
|
|
}
|