private object PopulateMultidimensionalArray(IList list, JsonReader reader, string reference, JsonArrayContract contract)
		{
			int rank = contract.UnderlyingType.GetArrayRank();

			if (reference != null)
				Serializer.ReferenceResolver.AddReference(this, reference, list);

			contract.InvokeOnDeserializing(list, Serializer.Context);

			//JsonContract collectionItemContract = GetContractSafe(contract.CollectionItemType);
			//JsonConverter collectionItemConverter = GetConverter(collectionItemContract, null, contract, containerProperty);

			//int? previousErrorIndex = null;
			Stack<IList> listStack = new Stack<IList>();
			listStack.Push(list);
			IList currentList = list;

			bool finished = false;
			do
			{
				int initialDepth = reader.Depth;

				if (listStack.Count == rank)
				{
					if (ReadForTypeArrayHack(reader, contract.CollectionItemType))
					{
						switch (reader.TokenType)
						{
							case JsonToken.EndArray:
								listStack.Pop();
								currentList = listStack.Peek();
								//previousErrorIndex = null;
								break;
							case JsonToken.Comment:
								break;
							default:
								try
								{
									object value = CreateValueNonProperty(reader, contract.CollectionItemType, GetContractSafe(contract.CollectionItemType));

									currentList.Add(value);
								}
								catch (Exception ex)
								{
									if (IsErrorHandled(list, contract, currentList.Count, ex))
										HandleError(reader, initialDepth);
									else
										throw;
								}
								break;
						}
					}
					else
					{
						break;
					}


				}
				else
				{
					if (reader.Read())
					{
						switch (reader.TokenType)
						{
							case JsonToken.StartArray:
								IList newList = new List<object>();
								currentList.Add(newList);
								listStack.Push(newList);
								currentList = newList;
								break;
							case JsonToken.EndArray:
								listStack.Pop();

								if (listStack.Count > 0)
								{
									currentList = listStack.Peek();
								}
								else
								{
									finished = true;
								}
								break;
							case JsonToken.Comment:
								break;
							default:
								throw new JsonSerializationException("Unexpected token when deserializing multidimensional array: " + reader.TokenType);
						}
					}
					else
					{
						break;
					}
				}
			} while (!finished);

			if (!finished)
				throw new JsonSerializationException("Unexpected end when deserializing array." + reader.TokenType);

			contract.InvokeOnDeserialized(list, Serializer.Context);
			return list;
		}
		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;

			while (ReadForTypeArrayHack(reader, contract.CollectionItemType))
			{
				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, GetContractSafe(contract.CollectionItemType));

							wrappedList.Add(value);
						}
						catch (Exception ex)
						{
							if (IsErrorHandled(list, contract, wrappedList.Count, ex))
								HandleError(reader, initialDepth);
							else
								throw;
						}
						break;
				}
			}

			throw new JsonSerializationException("Unexpected end when deserializing array.");
		}