MultitenantContainer Class |
Namespace: Autofac.Multitenant
The MultitenantContainer type exposes the following members.
Name | Description | |
---|---|---|
MultitenantContainer |
Initializes a new instance of the MultitenantContainer class.
|
Name | Description | |
---|---|---|
ApplicationContainer |
Gets the base application container.
| |
ComponentRegistry |
Gets the current tenant's registry that associates services with the
components that provide them.
| |
DiagnosticSource |
Gets the DiagnosticListener to which
trace events should be written.
| |
Disposer |
Gets the disposer associated with the current tenant's ILifetimeScope.
Component instances can be associated with it manually if required.
| |
IsDisposed |
Gets a value indicating whether the current instance has been disposed.
(Inherited from Disposable.) | |
Tag |
Gets the tag applied to the current tenant's ILifetimeScope.
| |
TenantIdentificationStrategy |
Gets the strategy used for identifying the current tenant.
|
Name | Description | |
---|---|---|
BeginLifetimeScope |
Begin a new nested scope for the current tenant. Component instances created via the new scope
will be disposed along with it.
| |
BeginLifetimeScope(Object) |
Begin a new nested scope for the current tenant. Component instances created via the new scope
will be disposed along with it.
| |
BeginLifetimeScope(ActionContainerBuilder) |
Begin a new nested scope for the current tenant, with additional
components available to it. Component instances created via the new scope
will be disposed along with it.
| |
BeginLifetimeScope(Object, ActionContainerBuilder) |
Begin a new nested scope for the current tenant, with additional
components available to it. Component instances created via the new scope
will be disposed along with it.
| |
ClearTenants |
Clears all tenants configurations and disposes the associated lifetime scopes.
| |
ConfigureTenant |
Allows configuration of tenant-specific components. You may only call this
method if the tenant is not currently configured.
| |
Dispose |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from Disposable.) | |
Dispose(Boolean) |
Releases unmanaged and - optionally - managed resources.
(Overrides DisposableDispose(Boolean).) | |
DisposeAsync | (Inherited from Disposable.) | |
DisposeAsync(Boolean) |
Releases unmanaged and - optionally - managed resources - possibly async.
(Overrides DisposableDisposeAsync(Boolean).) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetCurrentTenantScope |
Retrieves the lifetime scope for the current tenant based on execution
context.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetTenants |
Returns collection of all registered tenants IDs.
| |
GetTenantScope |
Retrieves the lifetime scope for a specific tenant.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ReconfigureTenant |
Allows re-configuration of tenant-specific components by closing and rebuilding
the tenant scope.
| |
RemoveTenant |
Removes the tenant configuration and disposes the associated lifetime scope.
| |
ResolveComponent |
Resolve an instance of the provided registration within the current tenant context.
| |
TenantIsConfigured |
Returns whether the given tenant ID has been configured.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
ChildLifetimeScopeBeginning |
Fired when a new scope based on the current scope is beginning.
| |
CurrentScopeEnding |
Fired when this scope is ending.
| |
ResolveOperationBeginning |
Fired when a resolve operation is beginning in this scope.
|
Name | Description | |
---|---|---|
InjectPropertiesTService(TService) | Overloaded.
Set any properties on instance that can be
resolved in the context.
(Defined by ResolutionExtensions.) | |
InjectPropertiesTService(TService, IEnumerableParameter) | Overloaded.
Set any properties on instance that can be
resolved in the context.
(Defined by ResolutionExtensions.) | |
InjectPropertiesTService(TService, Parameter) | Overloaded.
Set any properties on instance that can be
resolved in the context.
(Defined by ResolutionExtensions.) | |
InjectPropertiesTService(TService, IPropertySelector) | Overloaded.
Set any properties on instance that can be resolved by service and that satisfy the
constraints imposed by propertySelector.
(Defined by ResolutionExtensions.) | |
InjectPropertiesTService(TService, IPropertySelector, IEnumerableParameter) | Overloaded.
Set any properties on instance that can be resolved by service and that satisfy the
constraints imposed by propertySelector.
(Defined by ResolutionExtensions.) | |
InjectPropertiesTService(TService, IPropertySelector, Parameter) | Overloaded.
Set any properties on instance that can be resolved by service and that satisfy the
constraints imposed by propertySelector.
(Defined by ResolutionExtensions.) | |
InjectUnsetPropertiesTService(TService) | Overloaded.
Set any null-valued properties on instance that can be
resolved by the container.
(Defined by ResolutionExtensions.) | |
InjectUnsetPropertiesTService(TService, IEnumerableParameter) | Overloaded.
Set any null-valued properties on instance that can be
resolved by the container.
(Defined by ResolutionExtensions.) | |
InjectUnsetPropertiesTService(TService, Parameter) | Overloaded.
Set any null-valued properties on instance that can be
resolved by the container.
(Defined by ResolutionExtensions.) | |
IsRegistered(Type) | Overloaded.
Determine whether the specified service is available in the context.
(Defined by ResolutionExtensions.) | |
IsRegisteredTService | Overloaded.
Determine whether the specified service is available in the context.
(Defined by ResolutionExtensions.) | |
IsRegisteredService |
Determine whether the specified service is available in the context.
(Defined by ResolutionExtensions.) | |
IsRegisteredWithKey(Object, Type) | Overloaded.
Determine whether the specified service is available in the context.
(Defined by ResolutionExtensions.) | |
IsRegisteredWithKeyTService(Object) | Overloaded.
Determine whether the specified service is available in the context.
(Defined by ResolutionExtensions.) | |
IsRegisteredWithName(String, Type) | Overloaded.
Determine whether the specified service is available in the context.
(Defined by ResolutionExtensions.) | |
IsRegisteredWithNameTService(String) | Overloaded.
Determine whether the specified service is available in the context.
(Defined by ResolutionExtensions.) | |
Resolve(Type) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
Resolve(Type, IEnumerableParameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
Resolve(Type, Parameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveTService | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveTService(IEnumerableParameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveTService(Parameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveExportsT | Overloaded.
Locate all of the MEF exports registered as supplying contract type T.
(Defined by RegistrationExtensions.) | |
ResolveExportsT(String) | Overloaded.
Locate all of the MEF exports registered as supplying contract type T.
(Defined by RegistrationExtensions.) | |
ResolveKeyed(Object, Type) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveKeyed(Object, Type, IEnumerableParameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveKeyed(Object, Type, Parameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveKeyedTService(Object) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveKeyedTService(Object, IEnumerableParameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveKeyedTService(Object, Parameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveNamed(String, Type) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveNamed(String, Type, IEnumerableParameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveNamed(String, Type, Parameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveNamedTService(String) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveNamedTService(String, IEnumerableParameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveNamedTService(String, Parameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveOptional(Type) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptional(Type, IEnumerableParameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptional(Type, Parameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalTService | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalTService | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalTService(IEnumerableParameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalTService(Parameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalTService(IEnumerableParameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalTService(Parameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalKeyedTService(Object) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalKeyedTService(Object) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalKeyedTService(Object, IEnumerableParameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalKeyedTService(Object, Parameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalKeyedTService(Object, IEnumerableParameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalKeyedTService(Object, Parameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalNamedTService(String) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalNamedTService(String) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalNamedTService(String, IEnumerableParameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalNamedTService(String, Parameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalNamedTService(String, IEnumerableParameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalNamedTService(String, Parameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionValueExtensions.) | |
ResolveOptionalService(Service) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalService(Service, IEnumerableParameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveOptionalService(Service, Parameter) | Overloaded.
Retrieve a service from the context, or null if the service is not
registered.
(Defined by ResolutionExtensions.) | |
ResolveService(Service) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveService(Service, IEnumerableParameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
ResolveService(Service, Parameter) | Overloaded.
Retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
SubscribeToDiagnostics(DiagnosticTracerBase) | Overloaded.
Subscribes a diagnostic tracer to Autofac events.
(Defined by ContainerExtensions.) | |
SubscribeToDiagnosticsT | Overloaded.
Subscribes a diagnostic tracer to Autofac events.
(Defined by ContainerExtensions.) | |
TryResolve(Type, Object) | Overloaded.
Try to retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
TryResolveT(T) | Overloaded.
Try to retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
TryResolveT(NullableT) | Overloaded.
Try to retrieve a service from the context.
(Defined by ResolutionValueExtensions.) | |
TryResolveKeyed |
Try to retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
TryResolveNamed |
Try to retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
TryResolveService(Service, Object) | Overloaded.
Try to retrieve a service from the context.
(Defined by ResolutionExtensions.) | |
TryResolveService(Service, IEnumerableParameter, Object) | Overloaded.
Try to retrieve a service from the context.
(Defined by ResolutionExtensions.) |
This container implementation modifies the definition of the standard container implementation by returning values that are tenant-specific. For example, resolving a component via ResolveComponent(ResolveRequest) will yield a resolution of the dependency for the current tenant, not from a global container/lifetime.
The "current tenant ID" is resolved from an implementation of ITenantIdentificationStrategy that is passed into the container during construction.
The ability to remove (RemoveTenant(Object)) or reconfigure (ReconfigureTenant(Object, ActionContainerBuilder) an active tenant exists. However, it must still be noted that tenant lifetime scopes are immutable: once they are retrieved, configured, or an item is resolved, that tenant lifetime scope cannot be updated or otherwise changed. This is important since it means you need to configure your defaults and tenant overrides early, in application startup.
Even when using ReconfigureTenant(Object, ActionContainerBuilder), the existing tenant scope isn't modified, but is disposed and rebuilt. Any dependencies that were resolved from a removed scope will also be disposed. You will need to account for this in your application. Depending on your architecture, it may require users to re-login or some other form of soft reset.
If you do not configure a tenant lifetime scope for a tenant but resolve a tenant-specific dependency for that tenant, the lifetime scope will be implicitly created for you.
You may explicitly create and configure a tenant lifetime scope using the ConfigureTenant(Object, ActionContainerBuilder) method. If you need to perform some logic and build up the configuration for a tenant, you can do that using a ConfigurationActionBuilder.