Example #1
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            switch (type)
            {
            case TagTypes.Xiph:
                return(metadata.GetComment(create, tag));

            case TagTypes.FlacMetadata:
                return(metadata);
            }

            Tag t = (base.Tag as TagLib.NonContainer.Tag).GetTag(type);

            if (t != null || !create)
            {
                return(t);
            }

            switch (type)
            {
            case TagTypes.Id3v1:
                return(EndTag.AddTag(type, Tag));

            case TagTypes.Id3v2:
                return(StartTag.AddTag(type, Tag));

            case TagTypes.Ape:
                return(EndTag.AddTag(type, Tag));

            default:
                return(null);
            }
        }
Example #2
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        /// <remarks>
        ///    If a <see cref="TagLib.Id3v2.Tag" /> is added to the
        ///    current instance, it will be placed at the start of the
        ///    file. On the other hand, <see cref="TagLib.Id3v1.Tag" />
        ///    <see cref="TagLib.Ape.Tag" /> will be added to the end of
        ///    the file. All other tag types will be ignored.
        /// </remarks>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag t = (Tag as TagLib.NonContainer.Tag)
                           .GetTag(type);

            if (t != null || !create)
            {
                return(t);
            }

            switch (type)
            {
            case TagTypes.Id3v1:
                return(EndTag.AddTag(type, Tag));

            case TagTypes.Id3v2:
                return(StartTag.AddTag(type, Tag));

            case TagTypes.Ape:
                return(EndTag.AddTag(type, Tag));

            default:
                return(null);
            }
        }