Esempio n. 1
0
 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;
         }
     }
 }
Esempio n. 2
0
 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++;
 }
Esempio n. 3
0
        public void AddAttribute(string name, string value)
        {
            if (attributes == null)
            {
                return;
            }
            XmlAttr a = new XmlAttr(name, value);

            attributes.Add(a);
        }
Esempio n. 4
0
        public void PrependAttribute(string name, string value)
        {
            if (attributes == null)
            {
                return;
            }
            XmlAttr a = new XmlAttr(name, value);

            attributes.Insert(0, a);
        }
Esempio n. 5
0
        //
        // 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);
            }
        }
Esempio n. 6
0
        public bool GetAttribute(string attributeName, bool defaultValue)
        {
            XmlAttr a = FindAttr(attributeName);

            if (a == null)
            {
                return(defaultValue);
            }
            else
            {
                return(a.value ==
                       System.Boolean.TrueString);
            }
        }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
        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));
                }
            }
        }