Class MainDom
Provides the full implementation of IMainDom.
Inheritance
Namespace: Umbraco.Cms.Core.Runtime
Assembly: Umbraco.Core.dll
Syntax
public class MainDom : IMainDom, IRegisteredObject
Remarks
When an AppDomain starts, it tries to acquire the main domain status.
When an AppDomain stops (eg the application is restarting) it should release the main domain status.
Constructors
View SourceMainDom(ILogger<MainDom>, IMainDomLock)
Initializes a new instance of the MainDom class.
Declaration
[Obsolete("Use the constructor with all parameters. Scheduled for removal in Umbraco 19.")]
public MainDom(ILogger<MainDom> logger, IMainDomLock systemLock)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger<MainDom> | logger | The logger instance. |
| IMainDomLock | systemLock | The distributed lock implementation. |
MainDom(ILogger<MainDom>, IMainDomLock, IOptions<GlobalSettings>)
Initializes a new instance of the MainDom class.
Declaration
public MainDom(ILogger<MainDom> logger, IMainDomLock systemLock, IOptions<GlobalSettings> globalSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger<MainDom> | logger | The logger instance. |
| IMainDomLock | systemLock | The distributed lock implementation. |
| IOptions<GlobalSettings> | globalSettings | The global settings. |
Properties
View SourceIsMainDom
Gets a value indicating whether the current domain is the main domain.
Declaration
public bool IsMainDom { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Acquire must be called first else this will always return false
Methods
View SourceAcquire(IApplicationShutdownRegistry)
Tries to acquire the MainDom, returns true if successful else false
Declaration
public bool Acquire(IApplicationShutdownRegistry hostingEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IApplicationShutdownRegistry | hostingEnvironment |
Returns
| Type | Description |
|---|---|
| bool |
Dispose()
Declaration
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the MainDom and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
|
GetMainDomId(IHostingEnvironment)
Gets a unique identifier for the main domain based on the hosting environment.
Declaration
public static string GetMainDomId(IHostingEnvironment hostingEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IHostingEnvironment | hostingEnvironment | The hosting environment. |
Returns
| Type | Description |
|---|---|
| string | A SHA1 hash that uniquely identifies this application instance. |
Remarks
The ID is generated from the application ID and physical path to ensure uniqueness across multiple sites running on the same server.
Register(Action?, Action?, int)
Registers a resource that requires the current AppDomain to be the main domain to function.
Declaration
public bool Register(Action? install = null, Action? release = null, int weight = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | install | An action to execute when registering. |
| Action | release | An action to execute before the AppDomain releases the main domain status. |
| int | weight | An optional weight (lower goes first). |
Returns
| Type | Description |
|---|---|
| bool | A value indicating whether it was possible to register. |
Remarks
If registering is successful, then the install action
is guaranteed to execute before the AppDomain releases the main domain status.