-Improved Portable40 assembly performance by using compiled expression reflection
-Fixed converting string JValues to enums with JToken.ToObject
This commit is contained in:
@@ -187,13 +187,25 @@ namespace Newtonsoft.Json.Utilities
|
||||
#endif
|
||||
|
||||
public static PrimitiveTypeCode GetTypeCode(Type t)
|
||||
{
|
||||
bool isEnum;
|
||||
return GetTypeCode(t, out isEnum);
|
||||
}
|
||||
|
||||
public static PrimitiveTypeCode GetTypeCode(Type t, out bool isEnum)
|
||||
{
|
||||
PrimitiveTypeCode typeCode;
|
||||
if (TypeCodeMap.TryGetValue(t, out typeCode))
|
||||
{
|
||||
isEnum = false;
|
||||
return typeCode;
|
||||
}
|
||||
|
||||
if (t.IsEnum())
|
||||
{
|
||||
isEnum = true;
|
||||
return GetTypeCode(Enum.GetUnderlyingType(t));
|
||||
}
|
||||
|
||||
// performance?
|
||||
if (ReflectionUtils.IsNullableType(t))
|
||||
@@ -202,18 +214,15 @@ namespace Newtonsoft.Json.Utilities
|
||||
if (nonNullable.IsEnum())
|
||||
{
|
||||
Type nullableUnderlyingType = typeof(Nullable<>).MakeGenericType(Enum.GetUnderlyingType(nonNullable));
|
||||
isEnum = true;
|
||||
return GetTypeCode(nullableUnderlyingType);
|
||||
}
|
||||
}
|
||||
|
||||
isEnum = false;
|
||||
return PrimitiveTypeCode.Object;
|
||||
}
|
||||
|
||||
public static PrimitiveTypeCode GetTypeCode(object o)
|
||||
{
|
||||
return GetTypeCode(o.GetType());
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE)
|
||||
public static TypeInformation GetTypeInformation(IConvertible convertable)
|
||||
{
|
||||
@@ -623,7 +632,7 @@ namespace Newtonsoft.Json.Utilities
|
||||
|
||||
public static bool IsInteger(object value)
|
||||
{
|
||||
switch (GetTypeCode(value))
|
||||
switch (GetTypeCode(value.GetType()))
|
||||
{
|
||||
case PrimitiveTypeCode.SByte:
|
||||
case PrimitiveTypeCode.Byte:
|
||||
|
||||
Reference in New Issue
Block a user