using System; using System.Reflection; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Sync; namespace Umbraco.Core.Models { internal class Macro : Entity, IAggregateRoot { /// /// Creates an item with pre-filled properties /// /// /// /// /// /// /// /// /// /// /// /// /// public Macro(int id, bool useInEditor, int refreshRate, string @alias, string name, string controlType, string controlAssembly, string xsltPath, bool cacheByPage, bool cachePersonalized, bool dontRender, string scriptPath) { Id = id; UseInEditor = useInEditor; RefreshRate = refreshRate; Alias = alias; Name = name; ControlType = controlType; ControlAssembly = controlAssembly; XsltPath = xsltPath; CacheByPage = cacheByPage; CachePersonalized = cachePersonalized; DontRender = dontRender; ScriptPath = scriptPath; } /// /// Creates an instance for persisting a new item /// /// /// /// /// /// /// /// /// /// /// /// public Macro(string @alias, string name, string controlType = "", string controlAssembly = "", string xsltPath = "", string scriptPath = "", bool cacheByPage = false, bool cachePersonalized = false, bool dontRender = true, bool useInEditor = false, int refreshRate = 0) { UseInEditor = useInEditor; RefreshRate = refreshRate; Alias = alias; Name = name; ControlType = controlType; ControlAssembly = controlAssembly; XsltPath = xsltPath; CacheByPage = cacheByPage; CachePersonalized = cachePersonalized; DontRender = dontRender; ScriptPath = scriptPath; } public bool UseInEditor { get; set; } public int RefreshRate { get; set; } public string Alias { get; set; } public string Name { get; set; } public string ControlType { get; set; } public string ControlAssembly { get; set; } public string XsltPath { get; set; } public bool CacheByPage { get; set; } public bool CachePersonalized { get; set; } public bool DontRender { get; set; } public string ScriptPath { get; set; } } internal class ServerRegistration : Entity, IServerAddress, IAggregateRoot { private string _serverAddress; private string _computerName; private bool _isActive; private static readonly PropertyInfo ServerAddressSelector = ExpressionHelper.GetPropertyInfo(x => x.ServerAddress); private static readonly PropertyInfo ComputerNameSelector = ExpressionHelper.GetPropertyInfo(x => x.ComputerName); private static readonly PropertyInfo IsActiveSelector = ExpressionHelper.GetPropertyInfo(x => x.IsActive); public ServerRegistration() { } /// /// Creates an item with pre-filled properties /// /// /// /// /// /// /// public ServerRegistration(int id, string serverAddress, string computerName, DateTime createDate, DateTime updateDate, bool isActive) { UpdateDate = updateDate; CreateDate = createDate; Key = Id.ToString().EncodeAsGuid(); Id = id; ServerAddress = serverAddress; ComputerName = computerName; IsActive = isActive; } /// /// Creates a new instance for persisting a new item /// /// /// /// public ServerRegistration(string serverAddress, string computerName, DateTime createDate) { CreateDate = createDate; UpdateDate = createDate; Key = 0.ToString().EncodeAsGuid(); ServerAddress = serverAddress; ComputerName = computerName; } 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); } } public override string ToString() { return "(" + ServerAddress + ", " + ComputerName + ", IsActive = " + IsActive + ")"; } } }