Imported Upstream version 3.8.0

Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
This commit is contained in:
Jo Shields
2014-09-04 09:07:35 +01:00
parent a575963da9
commit fe777c5c82
1062 changed files with 12460 additions and 5983 deletions

View File

@ -180,16 +180,20 @@ namespace System.Web.Script.Serialization
return c.ConvertFrom (obj);
}
/*
* Take care of the special case whereas in JSON an empty string ("") really means
* an empty value
* (see: https://bugzilla.novell.com/show_bug.cgi?id=328836)
*/
if ((targetType.IsGenericType) && (targetType.GetGenericTypeDefinition() == typeof(Nullable<>)))
{
string s = obj as String;
if (String.IsNullOrEmpty(s))
if ((targetType.IsGenericType) && (targetType.GetGenericTypeDefinition () == typeof (Nullable<>))) {
if (obj is String) {
/*
* Take care of the special case whereas in JSON an empty string ("") really means
* an empty value
* (see: https://bugzilla.novell.com/show_bug.cgi?id=328836)
*/
if(String.IsNullOrEmpty ((String)obj))
return null;
} else if (c.CanConvertFrom (typeof (string))) {
TypeConverter objConverter = TypeDescriptor.GetConverter (obj);
string s = objConverter.ConvertToInvariantString (obj);
return c.ConvertFromInvariantString (s);
}
}
return Convert.ChangeType (obj, targetType);