Ejemplo n.º 1
0
 /// <summary>
 /// 获取或设置属性值
 /// </summary>
 /// <param name="name">属性名称</param>
 /// <param name="value">属性值</param>
 /// <returns>是否存在属性名称</returns>
 public bool Get(string name, ref string value)
 {
     if (attributes != null)
     {
         htmlText attribute = new htmlText();
         if (name != null && name.Length != 0 && attributes.TryGetValue(name = checkName(name.ToLower()), out attribute))
         {
             value = attribute.Text;
             if (attribute.FormatText != attribute.Text) attributes[name] = attribute;
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取或设置属性值
 /// </summary>
 /// <param name="name">属性名称</param>
 /// <returns>属性值</returns>
 public string this[string name]
 {
     get
     {
         if (attributes != null)
         {
             htmlText value = new htmlText();
             if (name != null && name.Length != 0 && attributes.TryGetValue(name = checkName(name.ToLower()), out value))
             {
                 if (value.FormatText != value.Text) attributes[name] = value;
             }
             return value.Text;
         }
         return null;
     }
     set
     {
         if (name != null && name.Length != 0)
         {
             if (value != null)
             {
                 if (attributes == null) attributes = new Dictionary<string, htmlText>();
                 attributes[checkName(name.ToLower())] = new htmlText { FormatText = value };
             }
             else if (attributes != null) attributes.Remove(checkName(name.ToLower()));
         }
     }
 }