public string this[string attributeName] { get { XmlAttr a = FindAttr(attributeName); if (a == null) { return(null); } return(a.value); } set { XmlAttr a = FindAttr(attributeName); if (a == null) { a = new XmlAttr(attributeName, value); attributes.Add(a); } else { a.value = value; } } }
public void PrependAttribute(string name, string value) { if (attributes == null) { attributes = new XmlAttr[defaultAttributesCapacity]; } else if (attributesUsed == attributes.Length) { XmlAttr[] dest = new XmlAttr[attributesUsed * 2]; for (int i = 0; i < attributesUsed; i++) { dest[i + 1] = attributes[i]; } attributes = dest; } else { //shift everything up one for (int i = attributesUsed; i > 0; i--) { attributes[i] = attributes[i - 1]; } } attributes[0] = new XmlAttr(name, value); attributesUsed++; }
public void AddAttribute(string name, string value) { if (attributes == null) { return; } XmlAttr a = new XmlAttr(name, value); attributes.Add(a); }
public void PrependAttribute(string name, string value) { if (attributes == null) { return; } XmlAttr a = new XmlAttr(name, value); attributes.Insert(0, a); }
// // Safe access to attributes: // since the kernel is going to use this object, we should // push the error-checking into the object instead of risking // the kernel forgetting to error check in some obscure method // public string GetAttribute(string attributeName, string defaultValue) { XmlAttr a = FindAttr(attributeName); if (a == null) { return(defaultValue); } else { return(a.value); } }
public bool GetAttribute(string attributeName, bool defaultValue) { XmlAttr a = FindAttr(attributeName); if (a == null) { return(defaultValue); } else { return(a.value == System.Boolean.TrueString); } }
public void AddAttribute(string name, string value) { if (attributes == null) { attributes = new XmlAttr[defaultAttributesCapacity]; } else if (attributesUsed == attributes.Length) { XmlAttr[] dest = new XmlAttr[attributesUsed * 2]; for (int i = 0; i < attributesUsed; i++) { dest[i] = attributes[i]; } attributes = dest; } attributes[attributesUsed++] = new XmlAttr(name, value); }
public UIntPtr GetAttributeAsUIntPtr(string attributeName, UIntPtr defaultValue) { XmlAttr a = FindAttr(attributeName); if (a == null) { return(defaultValue); } else { string num = a.value; if (num.StartsWith("0x") || num.StartsWith("0X")) { return(System.UIntPtr.Parse(num, NumberStyles.AllowHexSpecifier)); } else { return(System.UIntPtr.Parse(num)); } } }