using System; using System.Reflection; using System.Runtime.Serialization; using Umbraco.Core.Models.Entities; namespace Umbraco.Core.Models { /// /// Represents a Stylesheet Property /// /// /// Properties are always formatted to have a single selector, so it can be used in the backoffice /// [Serializable] [DataContract(IsReference = true)] public class StylesheetProperty : BeingDirtyBase, IValueObject { private string _alias; private string _value; public StylesheetProperty(string name, string @alias, string value) { Name = name; _alias = alias; _value = value; } private static readonly Lazy Ps = new Lazy(); private class PropertySelectors { public readonly PropertyInfo AliasSelector = ExpressionHelper.GetPropertyInfo(x => x.Alias); public readonly PropertyInfo ValueSelector = ExpressionHelper.GetPropertyInfo(x => x.Value); } /// /// The CSS rule name that can be used by Umbraco in the back office /// public string Name { get; private set; } /// /// This is the CSS Selector /// public string Alias { get { return _alias; } set { SetPropertyValueAndDetectChanges(value, ref _alias, Ps.Value.AliasSelector); } } /// /// The CSS value for the selector /// public string Value { get { return _value; } set { SetPropertyValueAndDetectChanges(value, ref _value, Ps.Value.ValueSelector); } } } }