using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.Serialization; using Umbraco.Core.Models.EntityBase; namespace Umbraco.Core.Models { /// /// Represents a member type /// [Serializable] [DataContract(IsReference = true)] public class MemberGroup : Entity, IMemberGroup { public MemberGroup() { AdditionalData = new Dictionary(); } private string _name; private int _creatorId; private static readonly Lazy Ps = new Lazy(); private class PropertySelectors { public readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name); public readonly PropertyInfo CreatorIdSelector = ExpressionHelper.GetPropertyInfo(x => x.CreatorId); } [DataMember] public string Name { get { return _name; } set { if (_name != value) { //if the name has changed, add the value to the additional data, //this is required purely for event handlers to know the previous name of the group //so we can keep the public access up to date. AdditionalData["previousName"] = _name; } SetPropertyValueAndDetectChanges(value, ref _name, Ps.Value.NameSelector); } } public int CreatorId { get { return _creatorId; } set { SetPropertyValueAndDetectChanges(value, ref _creatorId, Ps.Value.CreatorIdSelector); } } public IDictionary AdditionalData { get; private set; } } }