示例#1
0
文件: TextBlock.cs 项目: nistck/Jx
        public void SetAttribute(string name, string value)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new Exception("TextBlock: AddChild: \"name\" is null or empty.");
            }

            if (value == null)
            {
                throw new Exception("TextBlock: AddChild: \"value\" is null.");
            }

            for (int i = 0; i < this.attributes.Count; i++)
            {
                TextBlock.Attribute attribute = this.attributes[i];
                if (attribute.Name == name)
                {
                    attribute.value = value;
                    return;
                }
            }
            TextBlock.Attribute attr = new TextBlock.Attribute();
            attr.name  = name;
            attr.value = value;
            this.attributes.Add(attr);
        }
示例#2
0
文件: TextBlock.cs 项目: nistck/Jx
 public bool IsAttributeExist(string name)
 {
     for (int i = 0; i < this.attributes.Count; i++)
     {
         TextBlock.Attribute attribute = this.attributes[i];
         if (attribute.Name == name)
         {
             return(true);
         }
     }
     return(false);
 }
示例#3
0
文件: TextBlock.cs 项目: nistck/Jx
 public string GetAttribute(string name, string defaultValue)
 {
     for (int i = 0; i < this.attributes.Count; i++)
     {
         TextBlock.Attribute attribute = this.attributes[i];
         if (attribute.Name == name)
         {
             return(attribute.Value);
         }
     }
     return(defaultValue);
 }
示例#4
0
文件: TextBlock.cs 项目: nistck/Jx
 public void DeleteAttribute(string name)
 {
     for (int i = 0; i < this.attributes.Count; i++)
     {
         if (name == this.attributes[i].name)
         {
             TextBlock.Attribute attribute = this.attributes[i];
             attribute.name  = "";
             attribute.value = "";
             this.attributes.RemoveAt(i);
             return;
         }
     }
 }