Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 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;
         }
     }
 }