/// <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) { int index = objectTable.Count; var array = new BinaryPlistArray(objectTable); var item = new BinaryPlistItem(array); item.IsArray = true; objectTable.Add(item); foreach (object 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 (int i = 0; i < size; i++) { array.ObjectReference.Add((int)ReadInteger(reader, index + (i * objectRefSize), objectRefSize)); } return(array); }