示例#1
0
        ////------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Reads the <see cref="VorbisComments" /> from the stream.
        /// </summary>
        /// <param name="stream">The stream to read the <see cref="VorbisComments" /> from.</param>
        /// <returns>
        /// A <see cref="VorbisComments" /> instance if found; otherwise, null.
        /// <para />
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Thrown if stream is null.</exception>
        /// <exception cref="System.InvalidOperationException">
        /// stream can not be read
        /// or
        /// stream can not be seeked
        /// </exception>
        public static VorbisComments ReadStream(Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            if (!stream.CanRead)
                throw new InvalidOperationException("stream can not be read");

            if (!stream.CanSeek)
                throw new InvalidOperationException("stream can not be seeked");

            StreamBuffer sb = stream as StreamBuffer ?? new StreamBuffer(stream);

            long startPosition = sb.Position;

            VorbisComments vorbisComment = new VorbisComments();
            if (!vorbisComment.ReadStream(sb))
            {
                sb.Position = startPosition;
                return null;
            }
            return vorbisComment;
        }
示例#2
0
        /// <summary>
        /// Equals the specified <see cref="VorbisComments"/>.
        /// </summary>
        /// <param name="tag">The <see cref="VorbisComments"/>.</param>
        /// <returns>true if equal; false otherwise.</returns>
        public bool Equals(VorbisComments tag)
        {
            if (ReferenceEquals(null, tag))
                return false;

            if (ReferenceEquals(this, tag))
                return true;

            return String.Equals(Vendor, tag.Vendor, StringComparison.OrdinalIgnoreCase) && Comments.SequenceEqual(tag.Comments);
        }