/// <summary> /// Writes this element binary to the writer. /// </summary> /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param> /// <remarks>Provided for internal use only.</remarks> public void WriteBinary(PListBinaryWriter writer) { Byte[] keys = new Byte[writer.ElementIdxSize * Count]; Byte[] values = new Byte[writer.ElementIdxSize * Count]; long streamPos = writer.BaseStream.Position; writer.BaseStream.Write(keys, 0, keys.Length); writer.BaseStream.Write(values, 0, values.Length); KeyValuePair <String, IPListElement>[] elems = this.ToArray(); for (int i = 0; i < Count; i++) { int elementIdx = writer.WriteInternal(PListElementFactory.Instance.CreateKeyElement(elems[i].Key)); writer.FormatIdx(elementIdx).CopyTo(keys, writer.ElementIdxSize * i); } for (int i = 0; i < Count; i++) { int elementIdx = writer.WriteInternal(elems[i].Value); writer.FormatIdx(elementIdx).CopyTo(values, writer.ElementIdxSize * i); } writer.BaseStream.Seek(streamPos, SeekOrigin.Begin); writer.BaseStream.Write(keys, 0, keys.Length); writer.BaseStream.Write(values, 0, values.Length); writer.BaseStream.Seek(0, SeekOrigin.End); }
/// <summary> /// Writes this element binary to the writer. /// </summary> /// <param name="writer">The <see cref="T:CE.iPhone.PListBinaryWriter"/> to which the element is written.</param> /// <remarks>Provided for internal use only.</remarks> public void WriteBinary(PListBinaryWriter writer) { Byte[] elements = new Byte[writer.ElementIdxSize * Count]; long streamPos = writer.BaseStream.Position; writer.BaseStream.Write(elements, 0, elements.Length); for (int i = 0; i < Count; i++) { int elementIdx = writer.WriteInternal(this[i]); writer.FormatIdx(elementIdx).CopyTo(elements, writer.ElementIdxSize * i); } writer.BaseStream.Seek(streamPos, SeekOrigin.Begin); writer.BaseStream.Write(elements, 0, elements.Length); writer.BaseStream.Seek(0, SeekOrigin.End); }