-Added support for immutable collections

-Updated NUnit assembly source to NuGet
This commit is contained in:
James Newton-King
2013-07-09 00:12:09 +12:00
parent e49d8e8b02
commit 423d065c8f
31 changed files with 12684 additions and 33 deletions
@@ -68,7 +68,7 @@ namespace Newtonsoft.Json.Serialization
private Func<object> _genericTemporaryDictionaryCreator;
internal bool ShouldCreateWrapper { get; private set; }
internal ConstructorInfo ParametrizedConstructor { get; private set; }
internal MethodBase ParametrizedConstructor { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="JsonDictionaryContract"/> class.
@@ -117,7 +117,7 @@ namespace Newtonsoft.Json.Serialization
if (keyType != null && valueType != null)
ParametrizedConstructor = CollectionUtils.ResolveEnumableCollectionConstructor(CreatedType, typeof(KeyValuePair<,>).MakeGenericType(keyType, valueType));
ShouldCreateWrapper = !typeof (IDictionary).IsAssignableFrom(CreatedType);
ShouldCreateWrapper = !typeof(IDictionary).IsAssignableFrom(CreatedType);
DictionaryKeyType = keyType;
DictionaryValueType = valueType;
@@ -136,6 +136,17 @@ namespace Newtonsoft.Json.Serialization
ShouldCreateWrapper = true;
}
#endif
#if !(NET20 || NET35 || NET40 || PORTABLE40)
Type immutableCreatedType;
MethodBase immutableParameterizedCreator;
if (ImmutableCollectionsUtils.TryBuildImmutableForDictionaryContract(underlyingType, DictionaryKeyType, DictionaryValueType, out immutableCreatedType, out immutableParameterizedCreator))
{
CreatedType = immutableCreatedType;
ParametrizedConstructor = immutableParameterizedCreator;
IsReadOnlyOrFixedSize = true;
}
#endif
}
internal IWrappedDictionary CreateWrapper(object dictionary)