private void GetNamespaceToRender(
            [NotNull] string nsPrefix,
            [NotNull] SortedList attrListToRender,
            [NotNull] SortedList nsListToRender,
            [NotNull] Hashtable nsLocallyDeclared)
        {
            foreach (XmlAttribute key in nsListToRender.GetKeyList())
            {
                if (Exml.HasNamespacePrefix(key, nsPrefix))
                {
                    return;
                }
            }
            foreach (XmlNode key in attrListToRender.GetKeyList())
            {
                if (key.LocalName.Equals(nsPrefix))
                {
                    return;
                }
            }
            XmlAttribute a = (XmlAttribute)nsLocallyDeclared[nsPrefix];
            int          depth1;
            XmlAttribute withMatchingPrefix1 = GetNearestRenderedNamespaceWithMatchingPrefix(nsPrefix, out depth1);

            if (a != null)
            {
                if (!Exml.IsNonRedundantNamespaceDecl(a, withMatchingPrefix1))
                {
                    return;
                }
                nsLocallyDeclared.Remove(nsPrefix);
                if (Exml.IsXmlNamespaceNode(a))
                {
                    attrListToRender.Add(a, null);
                }
                else
                {
                    nsListToRender.Add(a, null);
                }
            }
            else
            {
                int depth2;
                var withMatchingPrefix2 = GetNearestUnrenderedNamespaceWithMatchingPrefix(nsPrefix, out depth2);
                if (withMatchingPrefix2 == null || depth2 <= depth1 || !Exml.IsNonRedundantNamespaceDecl(withMatchingPrefix2, withMatchingPrefix1))
                {
                    return;
                }
                if (Exml.IsXmlNamespaceNode(withMatchingPrefix2))
                {
                    attrListToRender.Add(withMatchingPrefix2, null);
                }
                else
                {
                    nsListToRender.Add(withMatchingPrefix2, null);
                }
            }
        }
        private void GatherNamespaceToRender(
            string nsPrefix,
            SortedList nsListToRender,
            Hashtable nsLocallyDeclared)
        {
            foreach (XmlAttribute key in (IEnumerable)nsListToRender.GetKeyList())
            {
                if (Exml.HasNamespacePrefix(key, nsPrefix))
                {
                    return;
                }
            }
            XmlAttribute a = (XmlAttribute)nsLocallyDeclared[(object)nsPrefix];
            int          depth1;
            XmlAttribute withMatchingPrefix1 = GetNearestRenderedNamespaceWithMatchingPrefix(nsPrefix, out depth1);

            if (a != null)
            {
                if (!Exml.IsNonRedundantNamespaceDecl(a, withMatchingPrefix1))
                {
                    return;
                }
                nsLocallyDeclared.Remove((object)nsPrefix);
                nsListToRender.Add((object)a, (object)null);
            }
            else
            {
                int          depth2;
                XmlAttribute withMatchingPrefix2 = GetNearestUnrenderedNamespaceWithMatchingPrefix(nsPrefix, out depth2);
                if (withMatchingPrefix2 == null || depth2 <= depth1 || !Exml.IsNonRedundantNamespaceDecl(withMatchingPrefix2, withMatchingPrefix1))
                {
                    return;
                }
                nsListToRender.Add((object)withMatchingPrefix2, (object)null);
            }
        }