using System; using System.Reflection; using System.Runtime.Serialization; using Umbraco.Core.Models.Entities; namespace Umbraco.Core.Models { /// /// Represents an audited event. /// [Serializable] [DataContract(IsReference = true)] internal class AuditEntry : EntityBase, IAuditEntry { private static PropertySelectors _selectors; private int _performingUserId; private string _performingDetails; private string _performingIp; private int _affectedUserId; private string _affectedDetails; private string _eventType; private string _eventDetails; private static PropertySelectors Selectors => _selectors ?? (_selectors = new PropertySelectors()); private class PropertySelectors { public readonly PropertyInfo PerformingUserId = ExpressionHelper.GetPropertyInfo(x => x.PerformingUserId); public readonly PropertyInfo PerformingDetails = ExpressionHelper.GetPropertyInfo(x => x.PerformingDetails); public readonly PropertyInfo PerformingIp = ExpressionHelper.GetPropertyInfo(x => x.PerformingIp); public readonly PropertyInfo AffectedUserId = ExpressionHelper.GetPropertyInfo(x => x.AffectedUserId); public readonly PropertyInfo AffectedDetails = ExpressionHelper.GetPropertyInfo(x => x.AffectedDetails); public readonly PropertyInfo EventType = ExpressionHelper.GetPropertyInfo(x => x.EventType); public readonly PropertyInfo EventDetails = ExpressionHelper.GetPropertyInfo(x => x.EventDetails); } /// public int PerformingUserId { get => _performingUserId; set => SetPropertyValueAndDetectChanges(value, ref _performingUserId, Selectors.PerformingUserId); } /// public string PerformingDetails { get => _performingDetails; set => SetPropertyValueAndDetectChanges(value, ref _performingDetails, Selectors.PerformingDetails); } /// public string PerformingIp { get => _performingIp; set => SetPropertyValueAndDetectChanges(value, ref _performingIp, Selectors.PerformingIp); } /// public DateTime EventDateUtc { get => CreateDate; set => CreateDate = value; } /// public int AffectedUserId { get => _affectedUserId; set => SetPropertyValueAndDetectChanges(value, ref _affectedUserId, Selectors.AffectedUserId); } /// public string AffectedDetails { get => _affectedDetails; set => SetPropertyValueAndDetectChanges(value, ref _affectedDetails, Selectors.AffectedDetails); } /// public string EventType { get => _eventType; set => SetPropertyValueAndDetectChanges(value, ref _eventType, Selectors.EventType); } /// public string EventDetails { get => _eventDetails; set => SetPropertyValueAndDetectChanges(value, ref _eventDetails, Selectors.EventDetails); } } }