Beispiel #1
0
        // Token: 0x06003216 RID: 12822 RVA: 0x00146C5C File Offset: 0x00144E5C
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, uint size)
        {
            ushort num = reader.ReadWord();

            if (settings.UnknownFileFormatPolicy == UnknownFileFormatPolicy.Abort && !Enum.IsDefined(typeof(MidiFileFormat), (int)num))
            {
                throw new UnknownFileFormatException(string.Format("File format {0} is unknown.", num), num);
            }
            this.FileFormat   = num;
            this.TracksNumber = reader.ReadWord();
            this.TimeDivision = TimeDivisionFactory.GetTimeDivision(reader.ReadInt16());
        }
        /// <summary>
        /// Reads content of a <see cref="HeaderChunk"/>.
        /// </summary>
        /// <remarks>
        /// Content of a <see cref="HeaderChunk"/> is format of the file, number of track chunks and time division.
        /// </remarks>
        /// <param name="reader">Reader to read the chunk's content with.</param>
        /// <param name="settings">Settings according to which the chunk's content must be read.</param>
        /// <param name="size">Expected size of the content taken from the chunk's header.</param>
        /// <exception cref="ObjectDisposedException">Method was called after the reader's underlying stream was disposed.</exception>
        /// <exception cref="IOException">An I/O error occurred on the reader's underlying stream.</exception>
        /// <exception cref="UnknownFileFormatException">The header chunk contains unknown file format and
        /// <see cref="ReadingSettings.UnknownFileFormatPolicy"/> property of the <paramref name="settings"/> set to
        /// <see cref="UnknownFileFormatPolicy.Abort"/>.</exception>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, uint size)
        {
            var fileFormat = reader.ReadWord();

            if (settings.UnknownFileFormatPolicy == UnknownFileFormatPolicy.Abort && !Enum.IsDefined(typeof(MidiFileFormat), fileFormat))
            {
                throw new UnknownFileFormatException($"File format {fileFormat} is unknown.", fileFormat);
            }

            FileFormat   = fileFormat;
            TracksNumber = reader.ReadWord();
            TimeDivision = TimeDivisionFactory.GetTimeDivision(reader.ReadInt16());
        }