/// <summary> /// Adds an array to the internal object table. /// </summary> /// <param name="value">The value to add.</param> /// <returns>The index of the added value.</returns> private int AddArray(IEnumerable value) { var index = _objectTable.Count; var array = new BinaryPlistArray(_objectTable); var item = new BinaryPlistItem(array) { IsArray = true }; _objectTable.Add(item); foreach (var obj in value) { array.ObjectReference.Add(AddObject(obj)); _objectRefCount++; } if (array.ObjectReference.Count < 15) { item.Marker.Add((byte)(0xA0 | (byte)array.ObjectReference.Count)); } else { item.Marker.Add(0xAF); AddIntegerCount(item.Marker, array.ObjectReference.Count); } _objectTableSize += item.Size; return(index); }
/// <summary> /// Reads an array value from the given reader, starting at the given index and of the given size. /// </summary> /// <param name="reader">The <see cref="BinaryReader" /> to read the array value from.</param> /// <param name="index">The index in the stream the array value starts at.</param> /// <param name="size">The number of items in the array.</param> /// <returns>An array value.</returns> private BinaryPlistArray ReadArray(BinaryReader reader, long index, int size) { var array = new BinaryPlistArray(_objectTable, size); for (var i = 0; i < size; i++) { array.ObjectReference.Add((int)ReadInteger(reader, index + i * _objectRefSize, _objectRefSize)); } return(array); }