2013-02-13 03:29:32 +06:00
|
|
|
|
using System;
|
2014-04-15 19:12:42 +10:00
|
|
|
|
using System.Globalization;
|
2013-03-21 00:05:56 +06:00
|
|
|
|
using System.Reflection;
|
2013-02-13 03:29:32 +06:00
|
|
|
|
using Umbraco.Core.Models.EntityBase;
|
2013-03-07 21:40:00 +06:00
|
|
|
|
using Umbraco.Core.Persistence.Mappers;
|
2013-02-13 03:29:32 +06:00
|
|
|
|
using Umbraco.Core.Sync;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Models
|
|
|
|
|
|
{
|
2013-03-07 21:40:00 +06:00
|
|
|
|
internal class ServerRegistration : Entity, IServerAddress, IAggregateRoot
|
|
|
|
|
|
{
|
2013-03-21 00:05:56 +06:00
|
|
|
|
private string _serverAddress;
|
|
|
|
|
|
private string _computerName;
|
|
|
|
|
|
private bool _isActive;
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly PropertyInfo ServerAddressSelector = ExpressionHelper.GetPropertyInfo<ServerRegistration, string>(x => x.ServerAddress);
|
|
|
|
|
|
private static readonly PropertyInfo ComputerNameSelector = ExpressionHelper.GetPropertyInfo<ServerRegistration, string>(x => x.ComputerName);
|
|
|
|
|
|
private static readonly PropertyInfo IsActiveSelector = ExpressionHelper.GetPropertyInfo<ServerRegistration, bool>(x => x.IsActive);
|
|
|
|
|
|
|
2013-03-07 21:40:00 +06:00
|
|
|
|
public ServerRegistration()
|
|
|
|
|
|
{
|
2013-02-20 21:55:02 +06:00
|
|
|
|
|
2013-03-07 21:40:00 +06:00
|
|
|
|
}
|
2013-02-13 03:29:32 +06:00
|
|
|
|
|
2013-03-07 21:40:00 +06:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Creates an item with pre-filled properties
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
|
/// <param name="serverAddress"></param>
|
|
|
|
|
|
/// <param name="computerName"></param>
|
|
|
|
|
|
/// <param name="createDate"></param>
|
|
|
|
|
|
/// <param name="updateDate"></param>
|
2013-03-28 11:27:13 +06:00
|
|
|
|
/// <param name="isActive"></param>
|
|
|
|
|
|
public ServerRegistration(int id, string serverAddress, string computerName, DateTime createDate, DateTime updateDate, bool isActive)
|
2013-03-07 21:40:00 +06:00
|
|
|
|
{
|
|
|
|
|
|
UpdateDate = updateDate;
|
|
|
|
|
|
CreateDate = createDate;
|
2014-04-15 19:12:42 +10:00
|
|
|
|
Key = Id.ToString(CultureInfo.InvariantCulture).EncodeAsGuid();
|
2013-03-07 21:40:00 +06:00
|
|
|
|
Id = id;
|
|
|
|
|
|
ServerAddress = serverAddress;
|
|
|
|
|
|
ComputerName = computerName;
|
2013-03-28 11:27:13 +06:00
|
|
|
|
IsActive = isActive;
|
2013-03-07 21:40:00 +06:00
|
|
|
|
}
|
2013-02-13 03:29:32 +06:00
|
|
|
|
|
2013-03-07 21:40:00 +06:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Creates a new instance for persisting a new item
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="serverAddress"></param>
|
|
|
|
|
|
/// <param name="computerName"></param>
|
|
|
|
|
|
/// <param name="createDate"></param>
|
|
|
|
|
|
public ServerRegistration(string serverAddress, string computerName, DateTime createDate)
|
|
|
|
|
|
{
|
|
|
|
|
|
CreateDate = createDate;
|
|
|
|
|
|
UpdateDate = createDate;
|
2014-04-15 19:12:42 +10:00
|
|
|
|
Key = 0.ToString(CultureInfo.InvariantCulture).EncodeAsGuid();
|
2013-03-07 21:40:00 +06:00
|
|
|
|
ServerAddress = serverAddress;
|
|
|
|
|
|
ComputerName = computerName;
|
|
|
|
|
|
}
|
2013-02-13 03:29:32 +06:00
|
|
|
|
|
2013-03-21 00:05:56 +06:00
|
|
|
|
public string ServerAddress
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _serverAddress; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetPropertyValueAndDetectChanges(o =>
|
|
|
|
|
|
{
|
|
|
|
|
|
_serverAddress = value;
|
|
|
|
|
|
return _serverAddress;
|
|
|
|
|
|
}, _serverAddress, ServerAddressSelector);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string ComputerName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _computerName; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetPropertyValueAndDetectChanges(o =>
|
|
|
|
|
|
{
|
|
|
|
|
|
_computerName = value;
|
|
|
|
|
|
return _computerName;
|
|
|
|
|
|
}, _computerName, ComputerNameSelector);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsActive
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _isActive; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetPropertyValueAndDetectChanges(o =>
|
|
|
|
|
|
{
|
|
|
|
|
|
_isActive = value;
|
|
|
|
|
|
return _isActive;
|
|
|
|
|
|
}, _isActive, IsActiveSelector);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-04-12 04:06:24 +06:00
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return "(" + ServerAddress + ", " + ComputerName + ", IsActive = " + IsActive + ")";
|
|
|
|
|
|
}
|
2013-03-07 21:40:00 +06:00
|
|
|
|
}
|
2013-02-13 03:29:32 +06:00
|
|
|
|
}
|