Interface ITenantContextMode
One way of resolving the current tenant, contributed by the package that provides it.
public interface ITenantContextMode
- Extension Methods
Remarks
Several packages can each supply a tenant context: the single-tenant default, the ambient context, and the HTTP context that reads the request principal. Each contributes a mode with AddTenantContextMode<TMode>(IServiceCollection), and ITenantContext resolves to the mode with the highest Precedence. The order in which modes are registered does not matter.
A mode of higher precedence is expected to cover what the lower ones cover: the HTTP mode falls back to the ambient tenant when there is no request, so registering it also serves background work. Two different modes with the same precedence are refused, at startup and on first resolution, rather than one being chosen silently.
Properties
Precedence
Gets the precedence of this mode. The highest precedence present is the one that resolves.
int Precedence { get; }
Property Value
- int
The single-tenant default is 0, the ambient context 1 and the HTTP context 2.
Methods
Create(IServiceProvider)
Creates the tenant context this mode provides.
ITenantContext Create(IServiceProvider services)
Parameters
servicesIServiceProviderThe root service provider.
Returns
- ITenantContext
The tenant context. It is resolved once and shared, so it must read the current tenant on each access rather than capture one.