Example #1
0
        /// <summary>
        /// Removes a style from the document.
        /// </summary>
        /// <param name="tag">Tag the style belongs to</param>
        /// <param name="styles">Style rule that contains the style to be removed</param>
        /// <param name="style">Style to be removed</param>
        /// <param name="reason">Reason for removal</param>
        private void RemoveStyle(IElement tag, ICssStyleDeclaration styles, ICssProperty style, RemoveReason reason)
        {
            var e = new RemovingStyleEventArgs {
                Tag = tag, Style = style, Reason = reason
            };

            OnRemovingStyle(e);
            if (!e.Cancel)
            {
                styles.RemoveProperty(style.Name);
            }
        }
Example #2
0
        /// <summary>
        /// 验证规则
        /// </summary>
        /// <param name="styles"></param>
        /// <returns></returns>
        protected virtual bool Validate(ICssStyleDeclaration styles)
        {
            if (styles == null)
            {
                return(false);
            }
            var removings = new List <ICssProperty>();

            foreach (ICssProperty item in styles)
            {
                if (!Validate(item))
                {
                    removings.Add(item);
                }
            }
            foreach (var item in removings)
            {
                styles.RemoveProperty(item.Name);
            }

            return(styles.Length > 0);
        }
 /// <summary>
 /// Remove a style from the document.
 /// </summary>
 /// <param name="tag">tag where the style belongs</param>
 /// <param name="styles">collection where the style to belongs</param>
 /// <param name="style">to be removed</param>
 /// <param name="reason">reason why to be removed</param>
 private void RemoveStyle(IElement tag, ICssStyleDeclaration styles, ICssProperty style, RemoveReason reason)
 {
     var e = new RemovingStyleEventArgs { Tag = tag, Style = style, Reason = reason };
     OnRemovingStyle(e);
     if (!e.Cancel) styles.RemoveProperty(style.Name);
 }