Files
Umbraco-CMS/src/Umbraco.Core/Models/ServerRegistration.cs
Mole bf41c2eeaa Netcore: Align namespaces (#9801)
* Rename Umbraco.Core namespace to Umbraco.Cms.Core

* Move extension methods in core project to Umbraco.Extensions

* Move extension methods in core project to Umbraco.Extensions

* Rename Umbraco.Examine namespace to Umbraco.Cms.Examine

* Move examine extensions to Umbraco.Extensions namespace

* Reflect changed namespaces in Builder and fix unit tests

* Adjust namespace in Umbraco.ModelsBuilder.Embedded

* Adjust namespace in Umbraco.Persistence.SqlCe

* Adjust namespace in Umbraco.PublishedCache.NuCache

* Align namespaces in Umbraco.Web.BackOffice

* Align namespaces in Umbraco.Web.Common

* Ensure that SqlCeSupport is still enabled after changing the namespace

* Align namespaces in Umbraco.Web.Website

* Align namespaces in Umbraco.Web.UI.NetCore

* Align namespaces in Umbraco.Tests.Common

* Align namespaces in Umbraco.Tests.UnitTests

* Align namespaces in Umbraco.Tests.Integration

* Fix errors caused by changed namespaces

* Fix integration tests

* Undo the Umbraco.Examine.Lucene namespace change

This breaks integration tests on linux, since the namespace wont exists there because it's only used on windows.

* Fix merge

* Fix Merge
2021-02-18 11:06:02 +01:00

125 lines
4.5 KiB
C#

using System;
using System.Globalization;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Models
{
/// <summary>
/// Represents a registered server in a multiple-servers environment.
/// </summary>
public class ServerRegistration : EntityBase, IServerRegistration
{
private string _serverAddress;
private string _serverIdentity;
private bool _isActive;
private bool _isMaster;
/// <summary>
/// Initializes a new instance of the <see cref="ServerRegistration"/> class.
/// </summary>
public ServerRegistration()
{ }
/// <summary>
/// Initializes a new instance of the <see cref="ServerRegistration"/> class.
/// </summary>
/// <param name="id">The unique id of the server registration.</param>
/// <param name="serverAddress">The server URL.</param>
/// <param name="serverIdentity">The unique server identity.</param>
/// <param name="registered">The date and time the registration was created.</param>
/// <param name="accessed">The date and time the registration was last accessed.</param>
/// <param name="isActive">A value indicating whether the registration is active.</param>
/// <param name="isMaster">A value indicating whether the registration is master.</param>
public ServerRegistration(int id, string serverAddress, string serverIdentity, DateTime registered, DateTime accessed, bool isActive, bool isMaster)
{
UpdateDate = accessed;
CreateDate = registered;
Key = id.ToString(CultureInfo.InvariantCulture).EncodeAsGuid();
Id = id;
ServerAddress = serverAddress;
ServerIdentity = serverIdentity;
IsActive = isActive;
IsMaster = isMaster;
}
/// <summary>
/// Initializes a new instance of the <see cref="ServerRegistration"/> class.
/// </summary>
/// <param name="serverAddress">The server URL.</param>
/// <param name="serverIdentity">The unique server identity.</param>
/// <param name="registered">The date and time the registration was created.</param>
public ServerRegistration(string serverAddress, string serverIdentity, DateTime registered)
{
CreateDate = registered;
UpdateDate = registered;
Key = 0.ToString(CultureInfo.InvariantCulture).EncodeAsGuid();
ServerAddress = serverAddress;
ServerIdentity = serverIdentity;
}
/// <summary>
/// Gets or sets the server URL.
/// </summary>
public string ServerAddress
{
get => _serverAddress;
set => SetPropertyValueAndDetectChanges(value, ref _serverAddress, nameof(ServerAddress));
}
/// <summary>
/// Gets or sets the server unique identity.
/// </summary>
public string ServerIdentity
{
get => _serverIdentity;
set => SetPropertyValueAndDetectChanges(value, ref _serverIdentity, nameof(ServerIdentity));
}
/// <summary>
/// Gets or sets a value indicating whether the server is active.
/// </summary>
public bool IsActive
{
get => _isActive;
set => SetPropertyValueAndDetectChanges(value, ref _isActive, nameof(IsActive));
}
/// <summary>
/// Gets or sets a value indicating whether the server is master.
/// </summary>
public bool IsMaster
{
get => _isMaster;
set => SetPropertyValueAndDetectChanges(value, ref _isMaster, nameof(IsMaster));
}
/// <summary>
/// Gets the date and time the registration was created.
/// </summary>
public DateTime Registered
{
get => CreateDate;
set => CreateDate = value;
}
/// <summary>
/// Gets the date and time the registration was last accessed.
/// </summary>
public DateTime Accessed
{
get => UpdateDate;
set => UpdateDate = value;
}
/// <summary>
/// Converts the value of this instance to its equivalent string representation.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return string.Format("{{\"{0}\", \"{1}\", {2}active, {3}master}}", ServerAddress, ServerIdentity, IsActive ? "" : "!", IsMaster ? "" : "!");
}
}
}