Exemplo n.º 1
0
        /// <summary>
        /// 绑定元素样式
        /// </summary>
        /// <param name="element">要处理的元素</param>
        /// <param name="styleAttributes">样式属性</param>
        private static void BindElementStyles(IHtmlElement element, IHtmlAttribute[] styleAttributes)
        {
            foreach (var attribute in styleAttributes)
            {
                var value = attribute.AttributeValue;
                var name  = attribute.Name.Substring(styleAttributePrefix.Length);

                attribute.Remove();

                if (string.IsNullOrEmpty(value))
                {
                    continue;
                }

                else
                {
                    element.Style(name, value);
                }
            }
        }
Exemplo n.º 2
0
    /// <summary>
    /// 绑定元素样式
    /// </summary>
    /// <param name="element">要处理的元素</param>
    /// <param name="styleAttributes">样式属性</param>
    private static void BindElementStyles( IHtmlElement element, IHtmlAttribute[] styleAttributes )
    {
      foreach ( var attribute in styleAttributes )
      {

        var value = attribute.AttributeValue;
        var name = attribute.Name.Substring( styleAttributePrefix.Length );

        attribute.Remove();

        if ( string.IsNullOrEmpty( value ) )
          continue;

        else
          element.Style( name, value );
      }
    }