-Refactor

This commit is contained in:
James Newton-King
2017-02-16 22:35:56 +13:00
parent 751c030da3
commit a1c5441e1d
@@ -2232,34 +2232,17 @@ namespace Newtonsoft.Json.Converters
{ {
foreach (IXmlNode xmlNode in c) foreach (IXmlNode xmlNode in c)
{ {
#if HAVE_XML_DOCUMENT if (xmlNode.NamespaceUri == JsonNamespaceUri)
// ignores the attribute if it is the declaration of namespace "JsonNamespaceUri"
var xmlAttribute = xmlNode.WrappedNode as XmlAttribute;
if (xmlAttribute != null &&
xmlAttribute.Prefix.Equals("xmlns", StringComparison.OrdinalIgnoreCase) &&
xmlAttribute.Value == JsonNamespaceUri)
{ {
continue; continue;
} }
#endif
#if HAVE_XLINQ if (xmlNode.NamespaceUri == "http://www.w3.org/2000/xmlns/" && xmlNode.Value == JsonNamespaceUri)
// ignores the attribute if it is the declaration of namespace "JsonNamespaceUri"
var xAttribute = xmlNode.WrappedNode as XAttribute;
if (xAttribute != null &&
xAttribute.IsNamespaceDeclaration &&
xAttribute.Value == JsonNamespaceUri)
{ {
continue; continue;
} }
#endif
if (xmlNode.NamespaceUri != JsonNamespaceUri) return true;
{
return true;
}
} }
return false; return false;