/// <summary> /// Saves the changes made in the current instance to the /// file it represents. /// </summary> public override void Save() { Mode = AccessMode.Write; try { HeaderObject header = new HeaderObject(this, 0); if (asf_tag == null) { header.RemoveContentDescriptors(); TagTypesOnDisk &= ~TagTypes.Asf; } else { TagTypesOnDisk |= TagTypes.Asf; header.AddUniqueObject( asf_tag.ContentDescriptionObject); header.AddUniqueObject( asf_tag.ExtendedContentDescriptionObject); header.Extension.AddUniqueObject( asf_tag.MetadataLibraryObject); } ByteVector output = header.Render(); long diff = output.Count - (long)header.OriginalSize; Insert(output, 0, (long)header.OriginalSize); InvariantStartPosition += diff; InvariantEndPosition += diff; } finally { Mode = AccessMode.Closed; } }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="Tag" /> using the children of a <see /// cref="HeaderObject" /> object. /// </summary> /// <param name="header"> /// A <see cref="HeaderObject" /> object whose children are /// are to be used by the new instance. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="header" /> is <see langword="null" />. /// </exception> public Tag(HeaderObject header) { if (header == null) { throw new ArgumentNullException("header"); } foreach (Object child in header.Children) { if (child is ContentDescriptionObject) { description = child as ContentDescriptionObject; } if (child is ExtendedContentDescriptionObject) { ext_description = child as ExtendedContentDescriptionObject; } } foreach (Object child in header.Extension.Children) { if (child is MetadataLibraryObject) { metadata_library = child as MetadataLibraryObject; } } }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="Tag" /> using the children of a <see /// cref="HeaderObject" /> object. /// </summary> /// <param name="header"> /// A <see cref="HeaderObject" /> object whose children are /// are to be used by the new instance. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="header" /> is <see langword="null" />. /// </exception> public Tag (HeaderObject header) { if (header == null) throw new ArgumentNullException ("header"); foreach (Object child in header.Children) { if (child is ContentDescriptionObject) description = child as ContentDescriptionObject; if (child is ExtendedContentDescriptionObject) ext_description = child as ExtendedContentDescriptionObject; } foreach (Object child in header.Extension.Children) if (child is MetadataLibraryObject) metadata_library = child as MetadataLibraryObject; }
private void Read(ReadStyle propertiesStyle) { Mode = AccessMode.Read; try { HeaderObject header = new HeaderObject(this, 0); if (header.HasContentDescriptors) { TagTypesOnDisk |= TagTypes.Asf; } asf_tag = new Asf.Tag(header); InvariantStartPosition = (long)header.OriginalSize; InvariantEndPosition = Length; if (propertiesStyle != ReadStyle.None) { properties = header.Properties; } } finally { Mode = AccessMode.Closed; } }
/// <summary> /// Reads the contents of the current instance. /// </summary> /// <param name="propertiesStyle"> /// A <see cref="ReadStyle" /> value specifying at what level /// of accuracy to read the media properties, or <see /// cref="ReadStyle.None" /> to ignore the properties. /// </param> private void Read(ReadStyle propertiesStyle) { Mode = AccessMode.Read; try { HeaderObject header = new HeaderObject (this, 0); if (header.HasContentDescriptors) TagTypesOnDisk |= TagTypes.Asf; asf_tag = new Asf.Tag (header); InvariantStartPosition = (long) header.OriginalSize; InvariantEndPosition = Length; if (propertiesStyle != ReadStyle.None) properties = header.Properties; } finally { Mode = AccessMode.Closed; } }
/// <summary> /// Saves the changes made in the current instance to the /// file it represents. /// </summary> public override void Save() { Mode = AccessMode.Write; try { HeaderObject header = new HeaderObject (this, 0); if (asf_tag == null) { header.RemoveContentDescriptors (); TagTypesOnDisk &= ~ TagTypes.Asf; } else { TagTypesOnDisk |= TagTypes.Asf; header.AddUniqueObject ( asf_tag.ContentDescriptionObject); header.AddUniqueObject ( asf_tag.ExtendedContentDescriptionObject); header.Extension.AddUniqueObject ( asf_tag.MetadataLibraryObject); } ByteVector output = header.Render (); long diff = output.Count - (long) header.OriginalSize; Insert (output, 0, (long) header.OriginalSize); InvariantStartPosition += diff; InvariantEndPosition += diff; } finally { Mode = AccessMode.Closed; } }