-Changed portable assembly to .NET 4.5, Silverlight 5, Win8, WP8
-Fixed incorrect namespace when converting XML to JSON
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
|
||||
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if (!(SILVERLIGHT || PORTABLE) || WINDOWS_PHONE)
|
||||
#if (!(SILVERLIGHT) || WINDOWS_PHONE)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -41,7 +41,7 @@ using System.Linq;
|
||||
namespace Newtonsoft.Json.Converters
|
||||
{
|
||||
#region XmlNodeWrappers
|
||||
#if !SILVERLIGHT && !NETFX_CORE
|
||||
#if !SILVERLIGHT && !NETFX_CORE && !PORTABLE
|
||||
internal class XmlDocumentWrapper : XmlNodeWrapper, IXmlDocument
|
||||
{
|
||||
private readonly XmlDocument _document;
|
||||
@@ -807,7 +807,7 @@ namespace Newtonsoft.Json.Converters
|
||||
if (value is XObject)
|
||||
return XContainerWrapper.WrapNode((XObject)value);
|
||||
#endif
|
||||
#if !(SILVERLIGHT || NETFX_CORE)
|
||||
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
if (value is XmlNode)
|
||||
return new XmlNodeWrapper((XmlNode)value);
|
||||
#endif
|
||||
@@ -972,15 +972,20 @@ namespace Newtonsoft.Json.Converters
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.PushScope();
|
||||
|
||||
string namespacePrefix = null;
|
||||
string namespaceUri = null;
|
||||
foreach (IXmlNode attribute in node.Attributes)
|
||||
{
|
||||
if (attribute.NamespaceUri == "http://www.w3.org/2000/xmlns/")
|
||||
{
|
||||
string prefix = (attribute.LocalName != "xmlns")
|
||||
? attribute.LocalName
|
||||
: string.Empty;
|
||||
namespacePrefix = (attribute.LocalName != "xmlns")
|
||||
? attribute.LocalName
|
||||
: string.Empty;
|
||||
namespaceUri = attribute.Value;
|
||||
|
||||
manager.AddNamespace(prefix, attribute.Value);
|
||||
manager.AddNamespace(namespacePrefix, namespaceUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1011,6 +1016,11 @@ namespace Newtonsoft.Json.Converters
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
if (namespacePrefix != null)
|
||||
manager.RemoveNamespace(namespacePrefix, namespaceUri);
|
||||
|
||||
manager.PopScope();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1092,7 +1102,7 @@ namespace Newtonsoft.Json.Converters
|
||||
rootNode = document;
|
||||
}
|
||||
#endif
|
||||
#if !(SILVERLIGHT || NETFX_CORE)
|
||||
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
if (typeof(XmlNode).IsAssignableFrom(objectType))
|
||||
{
|
||||
if (objectType != typeof (XmlDocument))
|
||||
@@ -1262,7 +1272,7 @@ namespace Newtonsoft.Json.Converters
|
||||
else if (reader.TokenType == JsonToken.Date)
|
||||
{
|
||||
DateTime d = Convert.ToDateTime(reader.Value, CultureInfo.InvariantCulture);
|
||||
#if !NETFX_CORE
|
||||
#if !(NETFX_CORE || PORTABLE)
|
||||
return XmlConvert.ToString(d, DateTimeUtils.ToSerializationMode(d.Kind));
|
||||
#else
|
||||
return XmlConvert.ToString(d);
|
||||
@@ -1555,7 +1565,7 @@ namespace Newtonsoft.Json.Converters
|
||||
if (typeof(XObject).IsAssignableFrom(valueType))
|
||||
return true;
|
||||
#endif
|
||||
#if !(SILVERLIGHT || NETFX_CORE)
|
||||
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
if (typeof(XmlNode).IsAssignableFrom(valueType))
|
||||
return true;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user