/// <summary> /// Constructs and initializes a new instance of <see /// cref="HeaderExtensionObject" /> by reading the contents /// from a specified position in a specified file. /// </summary> /// <param name="file"> /// A <see cref="Asf.File" /> object containing the file from /// which the contents of the new instance are to be read. /// </param> /// <param name="position"> /// A <see cref="long" /> value specify at what position to /// read the object. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="file" /> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="position" /> is less than zero or greater /// than the size of the file. /// </exception> /// <exception cref="CorruptFileException"> /// The object read from disk does not have the correct GUID /// or contents. /// </exception> public HeaderExtensionObject(File file, long position) : base(file, position) { if (!Guid.Equals(Asf.Guid.AsfHeaderExtensionObject)) { throw new CorruptFileException("Object GUID incorrect."); } if (file.ReadGuid() != Asf.Guid.AsfReserved1) { throw new CorruptFileException("Reserved1 GUID expected."); } if (file.ReadWord() != 6) { throw new CorruptFileException("Invalid reserved WORD. Expected '6'."); } uint size_remaining = file.ReadDWord(); position += 0x170 / 8; while (size_remaining > 0) { Object obj = file.ReadObject(position); position += (long)obj.OriginalSize; size_remaining -= (uint)obj.OriginalSize; children.Add(obj); } }