示例#1
0
		/// <summary>
		///    Copies the values from the current instance to another
		///    <see cref="TagLib.Tag" />, optionally overwriting
		///    existing values.
		/// </summary>
		/// <param name="target">
		///    A <see cref="Tag" /> object containing the target tag to
		///    copy values to.
		/// </param>
		/// <param name="overwrite">
		///    A <see cref="bool" /> specifying whether or not to copy
		///    values over existing one.
		/// </param>
		/// <remarks>
		///    <para>This method only copies the most basic values when
		///    copying between different tag formats, however, if
		///    <paramref name="target" /> is of the same type as the
		///    current instance, more advanced copying may be done.
		///    For example, <see cref="TagLib.Id3v2.Tag" /> will copy
		///    all of its frames to another tag.</para>
		/// </remarks>
		/// <exception cref="ArgumentNullException">
		///    <paramref name="target" /> is <see langword="null" />.
		/// </exception>
		public virtual void CopyTo (Tag target, bool overwrite)
		{
			if (target == null)
				throw new ArgumentNullException ("target");
			
			if (overwrite || IsNullOrLikeEmpty (target.Title))
				target.Title = Title;
			
			if (overwrite || IsNullOrLikeEmpty (target.AlbumArtists))
				target.AlbumArtists = AlbumArtists;
			
			if (overwrite || IsNullOrLikeEmpty (target.Performers))
				target.Performers = Performers;
			
			if (overwrite || IsNullOrLikeEmpty (target.Composers))
				target.Composers = Composers;
			
			if (overwrite || IsNullOrLikeEmpty (target.Album))
				target.Album = Album;
			
			if (overwrite || IsNullOrLikeEmpty (target.Comment))
				target.Comment = Comment;
			
			if (overwrite || IsNullOrLikeEmpty (target.Genres))
				target.Genres = Genres;
			
			if (overwrite || target.Year == 0)
				target.Year = Year;
			
			if (overwrite || target.Track == 0)
				target.Track = Track;
			
			if (overwrite || target.TrackCount == 0)
				target.TrackCount = TrackCount;
			
			if (overwrite || target.Disc == 0)
				target.Disc = Disc;
			
			if (overwrite || target.DiscCount == 0)
				target.DiscCount = DiscCount;
			
			if (overwrite || target.BeatsPerMinute == 0)
				target.BeatsPerMinute = BeatsPerMinute;
			
			if (overwrite || IsNullOrLikeEmpty (target.Grouping))
				target.Grouping = Grouping;
			
			if (overwrite || IsNullOrLikeEmpty (target.Conductor))
				target.Conductor = Conductor;
			
			if (overwrite || IsNullOrLikeEmpty (target.Copyright))
				target.Conductor = Copyright;
		}
示例#2
0
		public static void Duplicate (Tag source, Tag target,
		                              bool overwrite)
		{
			if (source == null)
				throw new ArgumentNullException ("source");
			
			if (target == null)
				throw new ArgumentNullException ("target");
			
			source.CopyTo (target, overwrite);
		}
示例#3
0
		/// <summary>
		///    Adds a tag at the end of the collection of tags in the
		///    current instance.
		/// </summary>
		/// <param name="tag">
		///    A <see cref="Tag" /> object to add to the collection of
		///    tags.
		/// </param>
		protected void AddTag (Tag tag)
		{
			this.tags.Add (tag);
		}
示例#4
0
		/// <summary>
		///    Removes a specified tag from the collection in the
		///    current instance.
		/// </summary>
		/// <param name="tag">
		///    A <see cref="Tag" /> object to remove from the
		///    collection.
		/// </param>
		protected void RemoveTag (Tag tag)
		{
			this.tags.Remove (tag);
		}
示例#5
0
		/// <summary>
		///    Inserts a tag into the collection of tags in the current
		///    instance.
		/// </summary>
		/// <param name="index">
		///    A <see cref="int" /> value specifying the index at which
		///    to insert the tag.
		/// </param>
		/// <param name="tag">
		///    A <see cref="Tag" /> object to insert into the collection
		///    of tags.
		/// </param>
		/// <exception cref="System.ArgumentOutOfRangeException">
		///    <paramref name="index" /> is less than zero or greater
		///    than the count.
		/// </exception>
		protected void InsertTag (int index, Tag tag)
		{
			this.tags.Insert (index, tag);
		}