Exemplo n.º 1
0
 /// <summary>
 ///    Removes all records with a given language, stream, and
 ///    name from the current instance.
 /// </summary>
 /// <param name="languageListIndex">
 ///    A <see cref="ushort" /> value containing the language
 ///    list index of the records to be removed.
 /// </param>
 /// <param name="streamNumber">
 ///    A <see cref="ushort" /> value containing the stream
 ///    number of the records to be removed.
 /// </param>
 /// <param name="name">
 ///    A <see cref="string" /> object containing the name of the
 ///    records to be removed.
 /// </param>
 public void RemoveRecords(ushort languageListIndex,
                           ushort streamNumber,
                           string name)
 {
     for (int i = records.Count - 1; i >= 0; i--)
     {
         DescriptionRecord rec = records [i];
         if (rec.LanguageListIndex == languageListIndex &&
             rec.StreamNumber == streamNumber &&
             rec.Name == name)
         {
             records.RemoveAt(i);
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///    Sets the a collection of records for a given language,
        ///    stream, and name, removing the existing matching records.
        /// </summary>
        /// <param name="languageListIndex">
        ///    A <see cref="ushort" /> value containing the language
        ///    list index of the records to be added.
        /// </param>
        /// <param name="streamNumber">
        ///    A <see cref="ushort" /> value containing the stream
        ///    number of the records to be added.
        /// </param>
        /// <param name="name">
        ///    A <see cref="string" /> object containing the name of the
        ///    records to be added.
        /// </param>
        /// <param name="records">
        ///    A <see cref="DescriptionRecord[]" /> containing records
        ///    to add to the new instance.
        /// </param>
        /// <remarks>
        ///    All added entries in <paramref name="records" /> should
        ///    match <paramref name="languageListIndex" />, <paramref
        ///    name="streamNumber" /> and <paramref name="name" /> but
        ///    it is not verified by the method. The records will be
        ///    added with their own values and not those provided in
        ///    this method, which are used for removing existing values
        ///    and determining where to position the new object.
        /// </remarks>
        public void SetRecords(ushort languageListIndex,
                               ushort streamNumber, string name,
                               params DescriptionRecord [] records)
        {
            int position = this.records.Count;

            for (int i = this.records.Count - 1; i >= 0; i--)
            {
                DescriptionRecord rec = this.records [i];
                if (rec.LanguageListIndex == languageListIndex &&
                    rec.StreamNumber == streamNumber &&
                    rec.Name == name)
                {
                    this.records.RemoveAt(i);
                    position = i;
                }
            }
            this.records.InsertRange(position, records);
        }
Exemplo n.º 3
0
        /// <summary>
        ///    Constructs and initializes a new instance of <see
        ///    cref="MetadataLibraryObject" /> 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 langref="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 smaller than the minimum size.
        /// </exception>
        public MetadataLibraryObject(Asf.File file, long position)
            : base(file, position)
        {
            if (!Guid.Equals(Asf.Guid.AsfMetadataLibraryObject))
            {
                throw new CorruptFileException(
                          "Object GUID incorrect.");
            }

            if (OriginalSize < 26)
            {
                throw new CorruptFileException(
                          "Object size too small.");
            }

            ushort count = file.ReadWord();

            for (ushort i = 0; i < count; i++)
            {
                DescriptionRecord rec = new DescriptionRecord(
                    file);
                AddRecord(rec);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 ///    Adds a record to the current instance.
 /// </summary>
 /// <param name="record">
 ///    A <see cref="DescriptionRecord" /> object to add to the
 ///    current instance.
 /// </param>
 public void AddRecord(DescriptionRecord record)
 {
     records.Add(record);
 }
		/// <summary>
		///    Constructs and initializes a new instance of <see
		///    cref="MetadataLibraryObject" /> 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 langref="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 smaller than the minimum size.
		/// </exception>
		public MetadataLibraryObject (Asf.File file, long position)
			: base (file, position)
		{
			if (!Guid.Equals (Asf.Guid.AsfMetadataLibraryObject))
				throw new CorruptFileException (
					"Object GUID incorrect.");
			
			if (OriginalSize < 26)
				throw new CorruptFileException (
					"Object size too small.");
			
			ushort count = file.ReadWord ();
			
			for (ushort i = 0; i < count; i ++) {
				DescriptionRecord rec = new DescriptionRecord (
					file);
				AddRecord (rec);
			}
		}
		/// <summary>
		///    Adds a record to the current instance.
		/// </summary>
		/// <param name="record">
		///    A <see cref="DescriptionRecord" /> object to add to the
		///    current instance.
		/// </param>
		public void AddRecord (DescriptionRecord record)
		{
			records.Add (record);
		}