public static XmlAttributeHolder[] ReadAttributes(XmlDictionaryReader reader, ref int maxSizeOfHeaders)
 {
     if (reader.AttributeCount == 0)
         return emptyArray;
     XmlAttributeHolder[] attributes = new XmlAttributeHolder[reader.AttributeCount];
     reader.MoveToFirstAttribute();
     for (int i = 0; i < attributes.Length; i++)
     {
         string ns = reader.NamespaceURI;
         string localName = reader.LocalName;
         string prefix = reader.Prefix;
         string value = string.Empty;
         while (reader.ReadAttributeValue())
         {
             if (value.Length == 0)
                 value = reader.Value;
             else
                 value += reader.Value;
         }
         Deduct(prefix, ref maxSizeOfHeaders);
         Deduct(localName, ref maxSizeOfHeaders);
         Deduct(ns, ref maxSizeOfHeaders);
         Deduct(value, ref maxSizeOfHeaders);
         attributes[i] = new XmlAttributeHolder(prefix, localName, ns, value);
         reader.MoveToNextAttribute();
     }
     reader.MoveToElement();
     return attributes;
 }
 public static void WriteAttributes(XmlAttributeHolder[] attributes, XmlWriter writer)
 {
     for (int i = 0; i < attributes.Length; i++)
         attributes[i].WriteTo(writer);
 }
 public static string GetAttribute(XmlAttributeHolder[] attributes, string localName, string ns)
 {
     for (int i = 0; i < attributes.Length; i++)
         if (attributes[i].LocalName == localName && attributes[i].NamespaceUri == ns)
             return attributes[i].Value;
     return null;
 }