Merge branch 'issue-143-dynamic-property-types' of https://github.com/Athari/Newtonsoft.Json into Athari-issue-143-dynamic-property-types

This commit is contained in:
James Newton-King
2013-12-08 11:35:13 +13:00
4 changed files with 14 additions and 47 deletions
+1 -12
View File
@@ -611,17 +611,6 @@ namespace Newtonsoft.Json.Linq
return ((ICustomTypeDescriptor)this).GetProperties(null);
}
private static Type GetTokenPropertyType(JToken token)
{
if (token is JValue)
{
JValue v = (JValue)token;
return (v.Value != null) ? v.Value.GetType() : typeof(object);
}
return token.GetType();
}
/// <summary>
/// Returns the properties for this instance of a component using the attribute array as a filter.
/// </summary>
@@ -635,7 +624,7 @@ namespace Newtonsoft.Json.Linq
foreach (KeyValuePair<string, JToken> propertyValue in this)
{
descriptors.Add(new JPropertyDescriptor(propertyValue.Key, GetTokenPropertyType(propertyValue.Value)));
descriptors.Add(new JPropertyDescriptor(propertyValue.Key));
}
return descriptors;
@@ -26,7 +26,6 @@
#if !(NETFX_CORE || PORTABLE || PORTABLE40)
using System;
using System.ComponentModel;
using Newtonsoft.Json.Utilities;
namespace Newtonsoft.Json.Linq
{
@@ -35,20 +34,13 @@ namespace Newtonsoft.Json.Linq
/// </summary>
public class JPropertyDescriptor : PropertyDescriptor
{
private readonly Type _propertyType;
/// <summary>
/// Initializes a new instance of the <see cref="JPropertyDescriptor"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="propertyType">Type of the property.</param>
public JPropertyDescriptor(string name, Type propertyType)
public JPropertyDescriptor(string name)
: base(name, null)
{
ValidationUtils.ArgumentNotNull(name, "name");
ValidationUtils.ArgumentNotNull(propertyType, "propertyType");
_propertyType = propertyType;
}
private static JObject CastInstance(object instance)
@@ -149,7 +141,7 @@ namespace Newtonsoft.Json.Linq
/// </returns>
public override Type PropertyType
{
get { return _propertyType; }
get { return typeof(object); }
}
/// <summary>