/// <summary> /// Writes the property Set To an output stream. /// </summary> /// <param name="out1">the output stream To Write the section To</param> public virtual void Write(Stream out1) { /* Write the number of sections in this property Set stream. */ int nrSections = sections.Count; int length = 0; /* Write the property Set's header. */ length += TypeWriter.WriteToStream(out1, (short)ByteOrder); length += TypeWriter.WriteToStream(out1, (short)Format); length += TypeWriter.WriteToStream(out1, OSVersion); length += TypeWriter.WriteToStream(out1, ClassID); length += TypeWriter.WriteToStream(out1, nrSections); int offset = OFFSET_HEADER; /* Write the section list, i.e. the references To the sections. Each * entry in the section list consist of the section's class ID and the * section's offset relative To the beginning of the stream. */ offset += nrSections * (ClassID.Length + LittleEndianConsts.INT_SIZE); int sectionsBegin = offset; for (IEnumerator i = sections.GetEnumerator(); i.MoveNext();) { MutableSection s = (MutableSection)i.Current; ClassID formatID = s.FormatID; if (formatID == null) { throw new NoFormatIDException(); } length += TypeWriter.WriteToStream(out1, s.FormatID); length += TypeWriter.WriteUIntToStream(out1, (uint)offset); offset += s.Size; } /* Write the sections themselves. */ offset = sectionsBegin; for (IEnumerator i = sections.GetEnumerator(); i.MoveNext();) { MutableSection s = (MutableSection)i.Current; offset += s.Write(out1); } /* Indicate that we're done */ out1.Close(); }