-Added support for falling back to IEnumerable<T> constructor on lists
-Added support for falling back to IEnumerable<KeyValuePair<TKey, TValue>> constructor on dictionaries
This commit is contained in:
@@ -69,6 +69,7 @@ namespace Newtonsoft.Json.Serialization
|
||||
|
||||
internal bool ShouldCreateWrapper { get; private set; }
|
||||
internal bool IsReadOnlyOrFixedSize { get; private set; }
|
||||
internal ConstructorInfo ParametrizedConstructor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="JsonDictionaryContract"/> class.
|
||||
@@ -101,6 +102,9 @@ namespace Newtonsoft.Json.Serialization
|
||||
ReflectionUtils.GetDictionaryKeyValueTypes(UnderlyingType, out keyType, out valueType);
|
||||
}
|
||||
|
||||
if (keyType != null && valueType != null)
|
||||
ParametrizedConstructor = CollectionUtils.ResolveEnumableCollectionConstructor(underlyingType, ReflectionUtils.MakeGenericType(typeof(KeyValuePair<,>), keyType, valueType));
|
||||
|
||||
ShouldCreateWrapper = !typeof (IDictionary).IsAssignableFrom(underlyingType);
|
||||
|
||||
DictionaryKeyType = keyType;
|
||||
|
||||
Reference in New Issue
Block a user