private object PopulateList(IWrappedCollection wrappedList, JsonReader reader, string reference, JsonArrayContract contract) { object list = wrappedList.UnderlyingCollection; // can't populate an existing array if (wrappedList.IsFixedSize) { reader.Skip(); return wrappedList.UnderlyingCollection; } if (reference != null) Serializer.ReferenceResolver.AddReference(this, reference, list); contract.InvokeOnDeserializing(list, Serializer.Context); int initialDepth = reader.Depth; JsonContract collectionItemContract = GetContractSafe(contract.CollectionItemType); JsonConverter collectionItemConverter = GetConverter(collectionItemContract, null); while (ReadForType(reader, collectionItemContract, collectionItemConverter != null, true)) { switch (reader.TokenType) { case JsonToken.EndArray: contract.InvokeOnDeserialized(list, Serializer.Context); return wrappedList.UnderlyingCollection; case JsonToken.Comment: break; default: try { object value = CreateValueNonProperty(reader, contract.CollectionItemType, collectionItemContract, collectionItemConverter); wrappedList.Add(value); } catch (Exception ex) { if (IsErrorHandled(list, contract, wrappedList.Count, ex)) { HandleError(reader, initialDepth); } else { throw; } } break; } } throw CreateSerializationException(reader, "Unexpected end when deserializing array."); }