-Added StringEscapeHandling with options to escape HTML and non-ASCII characters

-Added feature to deserialize ISet<T> properties as HashSet<T>
-Fixed ReferenceLoopHandling not being used when serializing ISerializable and dynamic values
This commit is contained in:
James Newton-King
2012-11-18 14:36:00 +13:00
parent f7018719d4
commit e3be3e43db
22 changed files with 515 additions and 38 deletions
@@ -85,9 +85,11 @@ namespace Newtonsoft.Json.Serialization
_isCollectionItemTypeNullableType = ReflectionUtils.IsNullableType(CollectionItemType);
if (IsTypeGenericCollectionInterface(UnderlyingType))
{
CreatedType = ReflectionUtils.MakeGenericType(typeof(List<>), CollectionItemType);
}
#if !(PORTABLE || NET20 || NET35 || WINDOWS_PHONE)
else if (IsTypeGenericSetnterface(UnderlyingType))
CreatedType = ReflectionUtils.MakeGenericType(typeof(HashSet<>), CollectionItemType);
#endif
IsMultidimensionalArray = (UnderlyingType.IsArray && UnderlyingType.GetArrayRank() > 1);
}
@@ -152,5 +154,17 @@ namespace Newtonsoft.Json.Serialization
|| genericDefinition == typeof(ICollection<>)
|| genericDefinition == typeof(IEnumerable<>));
}
#if !(PORTABLE || NET20 || NET35 || WINDOWS_PHONE)
private bool IsTypeGenericSetnterface(Type type)
{
if (!type.IsGenericType())
return false;
Type genericDefinition = type.GetGenericTypeDefinition();
return (genericDefinition == typeof(ISet<>));
}
#endif
}
}