Exemple #1
0
        /// <summary>
        /// Adds an Umbraco stylesheet property for use in the back office
        /// </summary>
        /// <param name="property"></param>
        public void AddProperty(IStylesheetProperty property)
        {
            if (Properties.Any(x => x.Name.InvariantEquals(property.Name)))
            {
                throw new DuplicateNameException("The property with the name " + property.Name + " already exists in the collection");
            }

            //now we need to serialize out the new property collection over-top of the string Content.
            Content = StylesheetHelper.AppendRule(Content, new StylesheetRule
            {
                Name     = property.Name,
                Selector = property.Alias,
                Styles   = property.Value
            });

            //re-set lazy collection
            InitializeProperties();
        }
Exemple #2
0
        public void Can_Update_Property()
        {
            // Arrange
            Stylesheet stylesheet = _builder
                                    .WithPath("/css/styles.css")
                                    .WithContent(@"body { color:#000; } /**umb_name:Hello*/p{font-size:2em;} .bold {font-weight:bold;}")
                                    .Build();

            // Act
            IStylesheetProperty prop = stylesheet.Properties.Single();

            prop.Alias = "li";
            prop.Value = "font-size:5em;";

            // - re-get
            prop = stylesheet.Properties.Single();

            // Assert
            Assert.AreEqual("li", prop.Alias);
            Assert.AreEqual("font-size:5em;", prop.Value);
            Assert.AreEqual("body { color:#000; } /**umb_name:Hello*/" + Environment.NewLine + "li {" + Environment.NewLine + "\tfont-size:5em;" + Environment.NewLine + "} .bold {font-weight:bold;}", stylesheet.Content);
        }