Click or drag to resize

MultitenantContainerConfigureTenant Method

Allows configuration of tenant-specific components. You may only call this method if the tenant is not currently configured.

Namespace:  Autofac.Multitenant
Assembly:  Autofac.Multitenant (in Autofac.Multitenant.dll) Version: 6.0.0+9a36082eb9b91dac82616d9efefa940b8c375948
Syntax
public void ConfigureTenant(
	Object tenantId,
	Action<ContainerBuilder> configuration
)

Parameters

tenantId
Type: SystemObject
The ID of the tenant for which configuration is occurring. If this value is , configuration occurs for the "default tenant" - the tenant that is used when no tenant ID can be determined.
configuration
Type: SystemActionContainerBuilder
An action that uses a ContainerBuilder to set up registrations for the tenant.
Exceptions
ExceptionCondition
ArgumentNullException Thrown if configuration is .
InvalidOperationException Thrown if the tenant indicated by tenantId has already been configured.
Remarks

If you need to configure a tenant across multiple registration calls, consider using a ConfigurationActionBuilder and configuring the tenant using the aggregate configuration action it produces.

Note that if GetTenantScope(Object) is called using the tenant ID, it builds the tenant scope with the default (container) configuration, which will also preclude the tenant from being configured. This includes the case where a dependency is resolved from the MultitenantContainer when the tenant ID is returned by the registered TenantIdentificationStrategy. If configuration can occur after application startup, use ReconfigureTenant(Object, ActionContainerBuilder) or "lock out" un-configured tenants using TenantIsConfigured(Object) or other mechanism.

See Also