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); }
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); }
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); }
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; } } }