Class TenantIdAccessor
- Namespace
- Cratis.Arc.Tenancy
- Assembly
- Cratis.Arc.Core.dll
Represents the current tenant accessor and explicit ITenantScope.
[Singleton]
public class TenantIdAccessor : ITenantIdAccessor, ITenantScope
- Inheritance
-
TenantIdAccessor
- Implements
- Inherited Members
- Extension Methods
Constructors
TenantIdAccessor(ITenantIdResolver)
Represents the current tenant accessor and explicit ITenantScope.
public TenantIdAccessor(ITenantIdResolver tenantIdResolver)
Parameters
tenantIdResolverITenantIdResolverThe ITenantIdResolver to use for resolving tenant IDs.
Properties
Current
Gets the current TenantId.
public TenantId Current { get; }
Property Value
Methods
Begin(TenantId)
Selects a tenant until the returned scope is disposed, including during an HTTP request.
public IDisposable Begin(TenantId tenant)
Parameters
tenantTenantIdThe tenant to select.
Returns
- IDisposable
A scope that restores the previously selected tenant on disposal. Disposal is idempotent; disposing an outer scope before an inner scope leaves the inner tenant selected, then restores resolution when the inner scope ends.
Remarks
A selected tenant takes precedence over the configured resolver, but does not authorize access to that tenant. Resolve tenant-scoped dependencies in a DI scope created after beginning this tenant scope.
Exceptions
- ArgumentNullException
The tenant is null.
- ArgumentException
The tenant ID is empty or whitespace.
- ExplicitTenantScopeRequiresArcAccessor
The effective tenant accessor does not support explicit scopes (raised when resolving this service).